关键词:
【中文标题】无法使用已装载存储的 Linux 部署 Azure 应用服务的 ARM 模板【英文标题】:Can not deploy ARM template of Azure App Service with Linux that has mounted storage 【发布时间】:2021-11-08 23:53:54 【问题描述】:我们正在尝试部署 Azure Linux 应用服务,该服务也已挂载存储。这是我们的 ARM 模板
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters":
"Environment":
"type": "String",
"allowedValues": [
"dev",
"stg",
"prd"
]
,
"Region":
"type": "string",
"allowedValues": [
"eu",
"we"
]
,
"MagentoMediaFileShareName":
"type": "string"
,
"StorageAccountName":
"type": "string"
,
"StorageAccountAccessKey":
"type": "securestring"
,
"MagentoMediaMountPath":
"type": "string",
"defaultValue": "/var/www/html/pub/external_media"
,
"variables":
"Location": "[resourceGroup().location]",
"ResourcePrefix": "[format('ariva-0-1-magento', parameters('Environment'), parameters('Region'))]",
"WebSiteName": "[concat(variables('ResourcePrefix'), '-web')]",
"ServicePlanId": "[format('/subscriptions/0/resourceGroups/ariva-1-2/providers/Microsoft.Web/serverfarms/ariva-1-2-asp', subscription().subscriptionId, parameters('Environment'), parameters('Region'))]"
,
"resources": [
"type": "Microsoft.Web/sites",
"apiVersion": "2020-12-01",
"name": "[variables('WebSiteName')]",
"location": "[variables('Location')]",
"kind": "app,linux,container",
"properties":
"enabled": true,
"hostNameSslStates": [
"name": "[concat(variables('WebSiteName'), '.azurewebsites.net')]",
"sslState": "Disabled",
"hostType": "Standard"
,
"name": "[concat(variables('WebSiteName'), '.scm.azurewebsites.net')]",
"sslState": "Disabled",
"hostType": "Repository"
],
"serverFarmId": "[variables('ServicePlanId')]",
"reserved": true,
"isXenon": false,
"hyperV": false,
"siteConfig":
"numberOfWorkers": 1,
"linuxFxVersion": "DOCKER|mcr.microsoft.com/appsvc/staticsite:latest",
"acrUseManagedIdentityCreds": false,
"alwaysOn": false,
"http20Enabled": false,
"functionAppScaleLimit": 0,
"minimumElasticInstanceCount": 1
,
"scmSiteAlsoStopped": false,
"clientAffinityEnabled": false,
"clientCertEnabled": false,
"clientCertMode": "Required",
"hostNamesDisabled": false,
"customDomainVerificationId": "1071794BD68C78EC0A4569F03C034F6E1B21BD4E6D35725D99523AC00AE12AA1",
"containerSize": 0,
"dailyMemoryTimeQuota": 0,
"keyVaultReferenceIdentity": "SystemAssigned",
"httpsOnly": false,
"redundancyMode": "None",
"storageAccountRequired": false
,
"type": "Microsoft.Web/sites/basicPublishingCredentialsPolicies",
"apiVersion": "2020-12-01",
"name": "[concat(variables('WebSiteName'), '/ftp')]",
"location": "[variables('Location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('WebSiteName'))]"
],
"properties":
"allow": true
,
"type": "Microsoft.Web/sites/basicPublishingCredentialsPolicies",
"apiVersion": "2020-12-01",
"name": "[concat(variables('WebSiteName'), '/scm')]",
"location": "[variables('Location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('WebSiteName'))]"
],
"properties":
"allow": true
,
"type": "Microsoft.Web/sites/config",
"apiVersion": "2020-12-01",
"name": "[concat(variables('WebSiteName'), '/web')]",
"location": "[variables('Location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('WebSiteName'))]"
],
"properties":
"numberOfWorkers": 1,
"defaultDocuments": [
"Default.htm",
"Default.html",
"Default.asp",
"index.htm",
"index.html",
"iisstart.htm",
"default.aspx",
"index.php",
"hostingstart.html"
],
"netFrameworkVersion": "v4.0",
"linuxFxVersion": "DOCKER|mcr.microsoft.com/appsvc/staticsite:latest",
"requestTracingEnabled": false,
"remoteDebuggingEnabled": false,
"remoteDebuggingVersion": "VS2019",
"httpLoggingEnabled": false,
"acrUseManagedIdentityCreds": false,
"logsDirectorySizeLimit": 35,
"detailedErrorLoggingEnabled": false,
"publishingUsername": "[concat('$', variables('WebSiteName'))]",
"azureStorageAccounts":
"magento-media":
"type": "AzureFiles",
"accountName": "[parameters('StorageAccountName')]",
"shareName": "[parameters('MagentoMediaFileShareName')]",
"mountPath": "[parameters('MagentoMediaMountPath')]",
"accessKey": "[parameters('StorageAccountAccessKey')]"
,
"scmType": "None",
"use32BitWorkerProcess": true,
"webSocketsEnabled": true,
"alwaysOn": true,
"managedPipelineMode": "Integrated",
"virtualApplications": [
"virtualPath": "/",
"physicalPath": "site\\wwwroot",
"preloadEnabled": false
],
"loadBalancing": "LeastRequests",
"experiments":
"rampUpRules": []
,
"autoHealEnabled": false,
"vnetRouteAllEnabled": false,
"vnetPrivatePortsCount": 0,
"localMySqlEnabled": false,
"ipSecurityRestrictions": [
"ipAddress": "Any",
"action": "Allow",
"priority": 1,
"name": "Allow all",
"description": "Allow all access"
],
"scmIpSecurityRestrictions": [
"ipAddress": "Any",
"action": "Allow",
"priority": 1,
"name": "Allow all",
"description": "Allow all access"
],
"scmIpSecurityRestrictionsUseMain": false,
"http20Enabled": true,
"minTlsVersion": "1.2",
"scmMinTlsVersion": "1.0",
"ftpsState": "AllAllowed",
"preWarmedInstanceCount": 0,
"functionAppScaleLimit": 0,
//"healthCheckPath": "/health_check.php",
"functionsRuntimeScaleMonitoringEnabled": false,
"minimumElasticInstanceCount": 1
,
"type": "Microsoft.Web/sites/hostNameBindings",
"apiVersion": "2020-12-01",
"name": "[concat(variables('WebSiteName'), '/', variables('WebSiteName'), '.azurewebsites.net')]",
"location": "[variables('Location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('WebSiteName'))]"
],
"properties":
"siteName": "[variables('WebSiteName')]",
"hostNameType": "Verified"
]
如果我们执行这个确切的模板,我们将收到以下错误
"status": "Failed",
"error":
"code": "BadRequest",
"message": "Required parameter AccessKey is missing.",
"details": [
"message": "Required parameter AccessKey is missing."
,
"code": "BadRequest"
,
]
如果我们通过门户手动挂载存储并尝试更改配置或添加部署槽,我们会收到相同的错误。
一旦我删除了挂载的存储配置,一切正常。
我们需要在我们的 DevOps 管道中使用它,在部署之前和之后手动卸载-重新安装存储是不可接受的。这将导致重大问题和停机时间。我们可以做些什么来克服这个问题?
更新 1
我尝试手动创建一个完全独立的网络应用程序和存储帐户。例如,当我连接存储挂载并尝试启用运行状况检查时,我得到了同样的错误。我认为 Azure 中存在错误。
更新 2
这是部署依赖存储帐户的模板
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters":
"Environment":
"type": "String",
"allowedValues": [
"dev",
"stg",
"prd"
]
,
"Region":
"type": "string",
"allowedValues": [
"eu",
"we"
]
,
"variables":
"Location": "[resourceGroup().location]",
"StorageAccountName": "[format('ariva01magentostorage', parameters('Environment'), parameters('Region'))]",
"MagentoMediaFileShareName": "magento-media"
,
"resources": [
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2021-04-01",
"name": "[variables('StorageAccountName')]",
"location": "[variables('Location')]",
"sku":
"name": "Standard_LRS",
"tier": "Standard"
,
"kind": "StorageV2",
"properties":
"allowCrossTenantReplication": true,
"minimumTlsVersion": "TLS1_2",
"allowBlobPublicAccess": true,
"allowSharedKeyAccess": true,
"networkAcls":
"resourceAccessRules": [],
"bypass": "AzureServices",
"virtualNetworkRules": [],
"ipRules": [],
"defaultAction": "Allow"
,
"supportsHttpsTrafficOnly": true,
"encryption":
"services":
"file":
"keyType": "Account",
"enabled": true
,
"blob":
"keyType": "Account",
"enabled": true
,
"keySource": "Microsoft.Storage"
,
"accessTier": "Hot"
,
"type": "Microsoft.Storage/storageAccounts/blobServices",
"apiVersion": "2021-04-01",
"name": "[concat(variables('StorageAccountName'), '/default')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('StorageAccountName'))]"
],
"sku":
"name": "Standard_LRS",
"tier": "Standard"
,
"properties":
"changeFeed":
"enabled": false
,
"restorePolicy":
"enabled": false
,
"containerDeleteRetentionPolicy":
"enabled": true,
"days": 7
,
"cors":
"corsRules": []
,
"deleteRetentionPolicy":
"enabled": true,
"days": 7
,
"isVersioningEnabled": false
,
"type": "Microsoft.Storage/storageAccounts/fileServices",
"apiVersion": "2021-04-01",
"name": "[concat(variables('StorageAccountName'), '/default')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('StorageAccountName'))]"
],
"sku":
"name": "Standard_LRS",
"tier": "Standard"
,
"properties":
"shareDeleteRetentionPolicy":
"enabled": true,
"days": 7
,
"type": "Microsoft.Storage/storageAccounts/queueServices",
"apiVersion": "2021-04-01",
"name": "[concat(variables('StorageAccountName'), '/default')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('StorageAccountName'))]"
],
"properties":
"cors":
"corsRules": []
,
"type": "Microsoft.Storage/storageAccounts/tableServices",
"apiVersion": "2021-04-01",
"name": "[concat(variables('StorageAccountName'), '/default')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('StorageAccountName'))]"
],
"properties":
"cors":
"corsRules": []
,
"type": "Microsoft.Storage/storageAccounts/fileServices/shares",
"apiVersion": "2021-04-01",
"name": "[concat(variables('StorageAccountName'), '/default/', variables('MagentoMediaFileShareName'))]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/fileServices', variables('StorageAccountName'), 'default')]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('StorageAccountName'))]"
],
"properties":
"accessTier": "TransactionOptimized",
"shareQuota": 5120,
"enabledProtocols": "SMB"
],
"outputs":
"MagentoMediaFileShareName":
"type": "string",
"value": "[variables('MagentoMediaFileShareName')]"
,
"StorageAccountName":
"type": "string",
"value": "[variables('StorageAccountName')]"
,
"StorageAccountAccessKey":
"type": "securestring",
"value": "[listKeys(variables('StorageAccountName'), '2019-04-01').keys[0].value]"
更新 3 - 临时解决方法
我们找到了临时解决方法。我们没有通过 ARM 模板部署文件挂载,而是从 ARM 模板中删除了该位,之后,我们在 DevOps 管道中使用以下构建步骤通过 azure CLI 挂载存储
- task: AzureCLI@2
displayName: 'Attach media volume'
inputs:
azureSubscription: '$ parameters.azureSubscription '
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
az webapp config storage-account add `
--resource-group $ parameters.resourceGroup `
--name "$(WebSiteName)" `
--access-key "$(StorageAccountAccessKey)" `
--custom-id magento-media `
--storage-type AzureFiles `
--share-name "$(MagentoMediaFileShareName)" `
--account-name "$(StorageAccountName)" `
--mount-path "/var/www/html/pub/external_media"
这当然不能解决问题。
-
这样做,ARM 模板将实质上移除挂载,然后由脚本部署,导致停机
挂载完成后,我们仍然无法通过门户更改任何 WebApp 属性,我们将收到缺少 AccessKey 的错误
【问题讨论】:
如何配置存储帐户的安全性?也只是为了确认,当//"healthCheckPath": "/health_check.php",
被评论时,您的模板会部署,但如果不是,您会收到错误消息?
@RyanHill-MSFT 我们正在另一个 ARM 模板中部署存储。我们没有任何特定的安全设置。我已经使用我们使用的存储 ARM 模板更新了帖子。然后,我们输出 AccessKey 并将其作为此部署的输入参数提供。至于健康检查,它还没有配置。当我们使用它时,它不会改变行为,无论有没有健康检查,我们仍然会收到 AccessKey 失败。我提到健康检查的原因是,当您通过 GUI 挂载存储并尝试添加健康检查时,会引发相同的错误。
在 Azure 门户中,您设置的存储帐户是否具有访问密钥?我没有遇到你在mounting the storage account to the app service 时遇到的同样问题。
您的设置应该类似于i.imgur.com/Qbwl5cb.png
非常感谢瑞恩。根据以下建议更改 ARM 模板后,就存储安装而言一切正常))
【参考方案1】:
azureStorageAccounts
不是Microsoft.Web sites/config 2020-12-01 的一部分,但它在Microsoft.Web sites 2020-12-01 SiteConfig
属性下。这可能是没有找到、没有上传 accessKey 的原因。我会把azureStorageAccounts
移到siteConfig
下面
【讨论】:
谢谢瑞恩。你其实是对的。这部分回答了我的问题。问题是当您将 WebApp 导出为 ARM 模板时,它会提供不同的 API 版本 2021-01-15,这在 Microsoft 文档中不可用。可用的版本是 2020-12-01,我只是用它替换了导出模板中的值。这显然不起作用,因为架构不同。我们该如何解决这种情况? 您可以使用ARM template tool test kit。如果我没记错的话,ARM 和 Bicep VS Code Extensions 中使用的 linter 就是利用了这个。 确实如此。 Linter 确实帮了一点忙。但我看到的主要问题是,当您导出 WebApp ARM 模板时,它不能开箱即用。此外,它引用的 API 版本至少没有记录,甚至可能不存在,并且 linter 抱怨该版本 我会看看我能找到与 API 版本相关的文档更新的内容。 这真是太棒了!感谢更新。我希望 json 架构也将被发布,以便 VS Code 扩展识别它。从 Azure 存储流式传输 blob - 无法访问已关闭的流
】从Azure存储流式传输blob-无法访问已关闭的流【英文标题】:StreamingablobfromAzurestorage-CannotaccessaclosedStream【发布时间】:2019-02-0623:13:13【问题描述】:我正在使用asp.net网络表单。我在Azure存储中有需要处理的pdf。我正在使用PDFJet... 查看详情
使用 Bicep 设置 Azure 存储帐户装载路径
】使用Bicep设置Azure存储帐户装载路径【英文标题】:SetAzureStorageAccountmountpathwithBicep【发布时间】:2021-11-0717:27:40【问题描述】:以前,使用AzureCLI脚本,我有以下存储帐户配置:azwebappconfigstorage-accountadd\\--resource-group$resourceGroup\... 查看详情
使用azure云资源搭建高可用服务
...务提供商去保证服务的可用性,高的有5个9的可用性,但无法避免会有不可用的时段。本文调研Azure的云服务器、rds存储等服务的特性,讨论一种可以保证web服务高可用的部署方案。2.Azure的产品特性2.1ecs2.2rds 3.部署方式todo&nbs... 查看详情
Azure Functions - 无法使用 VSCODE 扩展部署函数 - 部署在将 zip 包上传到存储容器时永远挂起
】AzureFunctions-无法使用VSCODE扩展部署函数-部署在将zip包上传到存储容器时永远挂起【英文标题】:AzureFunctions-Can\'tdeployfunctionsusingVSCODEextension-Deployhangsforeveratuploadingzippackagetostoragecontainer【发布时间】:2021-10-0319:08:55【问题描述... 查看详情
如何根据 Azure 中的部署名称删除所有已部署的资源
...nAzure【发布时间】:2016-03-2423:14:38【问题描述】:我正在使用ARM模板配置新的Azure环境。为了部署,我使用AzurePowerShellNew-AzureRmResourceGroupDeployment命令,我在其中指定Deployme 查看详情
Blazor Azure 部署错误:“错误:无法从存储库中检测到语言。”
】BlazorAzure部署错误:“错误:无法从存储库中检测到语言。”【英文标题】:BlazorAzuredeploymenterror:"Error:Couldnotdetectthelanguagefromrepo."【发布时间】:2021-12-2201:55:03【问题描述】:我正在尝试将Blazor.NET6应用程序部署到Azure... 查看详情
Azure 存储表访问出现无法解释的异步/等待问题 - 可以使用 ConfigureAwait(false) 解决吗?可能不是
】Azure存储表访问出现无法解释的异步/等待问题-可以使用ConfigureAwait(false)解决吗?可能不是【英文标题】:Unexplainedasync/awaitproblemwithAzureStorageTableaccess-isitOKtosolvewithConfigureAwait(false)?ProbablyNOT【发布时间】:2021-07-2205:51:01【问题描... 查看详情
使用 docker 映像在 azure kubernetes 上自动部署已更新:可能吗?
】使用docker映像在azurekubernetes上自动部署已更新:可能吗?【英文标题】:Autodeployonazurekubernateswhendockerimageisupdated:possible?【发布时间】:2019-11-0603:30:26【问题描述】:我使用azure的kubernates服务创建了一个应用程序。在我的yaml中... 查看详情
装载 Azure 文件共享
】装载Azure文件共享【英文标题】:MountAzurefileshare【发布时间】:2021-12-0819:15:14【问题描述】:我创建了一个公共Azure文件共享并将身份验证方法设置为ActiveDirectory。Azure存储帐户是加入我的本地ActiveDirectory域服务的域。我已经... 查看详情
无法访问仅具有虚拟网络访问权限的 Azure 存储帐户,尽管已成功连接到此虚拟网络的 Point 2 Site
】无法访问仅具有虚拟网络访问权限的Azure存储帐户,尽管已成功连接到此虚拟网络的Point2Site【英文标题】:NoaccesstoAzureStorageAccountwhichhasvirtualnetworkonlyaccess,despiteasuccesfulPoint2siteconnectiontothatvirtualnetwork【发布时间】:2021-11-1420:41:... 查看详情
将 DataBricks 连接到 Azure Blob 存储
...装载到DataBricks实例,虽然装载确实有效,但它似乎没有使用存储容器。这是我用来创建挂载的代码...storageAccountName=\'x\'blobContainerName=\'f 查看详情
无法通过 GitHub 将 Laravel php 应用程序部署到 azure
】无法通过GitHub将Laravelphp应用程序部署到azure【英文标题】:Can\'tdeployLaravelphpapptoazureviaGitHub【发布时间】:2021-07-1603:56:06【问题描述】:当尝试将包含Laravel应用程序的私有GitHub存储库连接到php堆栈上的天蓝色“Web应用程序+postg... 查看详情
7.azure文件(文件共享)-nas(上)
...本地部署同时装载。?取代或补充本地文件服务器:可以使用Azure文件来完全取代或补充传统的本地文件服务器或NAS设备。流行的操作系统(例如Windows、macOS和Linux)可在世界各 查看详情
无法将下一个 js 部署到 azure
】无法将下一个js部署到azure【英文标题】:unabletodeploynextjstoazure【发布时间】:2019-07-2108:43:04【问题描述】:我正在尝试将我的NEXTJS应用程序部署到azure。我创建了一个带有安装了Node的linux操作系统的web应用程序。我的package.json... 查看详情
7.azure文件(文件共享)-nas(上)
...的本地部署同时装载。取代或补充本地文件服务器:可以使用Azure文件来完全取代或补充传统的本地文件服务器或NAS设备。流行的操作系统(例如Windows、macOS和Linux)可在世界各地 查看详情
Azure 函数和 Azure 存储 - 实体已存在 - nodeJS
...看起来有时尝试插入的实体已经存在于我的表中。RowKey是使用两个4位数字的数学随机生成的,我知道这可 查看详情
无法使用 Azure Fluent 获取存储帐户密钥
】无法使用AzureFluent获取存储帐户密钥【英文标题】:UnabletogetstorageaccountkeywithAzureFluent【发布时间】:2019-01-1420:10:13【问题描述】:我使用AzureFluentSDK创建了一个存储帐户。但在创建存储帐户后,我想获取名称和密钥来构建可用... 查看详情
在 Azure 容器实例中部署机器学习模型时如何访问所有已注册的模型?
...道,用于训练机器学习模型并将其部署到生产环境中。它使用Py 查看详情