azure - ARM 模板创建存储帐户和应用服务时出错
问题描述
是否可以使用 ARM 模板在同一资源组中创建服务计划、应用服务和存储帐户?,当我尝试此操作时,我收到下一个错误:
Azure 错误:InvalidTemplateDeployment 消息:根据验证过程,模板部署“XXXX”无效。跟踪 ID 为“XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX”。有关详细信息,请参阅内部错误。异常详细信息:错误代码:PreflightValidationCheckFailed 消息:预检验证失败。具体错误请参考详细信息。
但是如果我使用不同的资源组和不同的模板,这个效果很好。
完整的 ARM 模板是:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"webAppName": {
"type": "String",
"metadata": {
"description": "The App Service name."
}
},
"sku": {
"type": "string",
"defaultValue": "F1",
"metadata": {
"description": "The SKU of App Service Plan."
}
},
"storageAccountName": {
"type": "string",
"metadata": {
"description": "The Storage Account name."
}
}
},
"variables": {
"appServicePlanName": "[concat('AppServicePlan-', parameters('webAppName'))]",
"location": "[resourceGroup().location]"
},
"resources": [
//App services plan
{
"apiVersion": "2020-06-01",
"type": "Microsoft.Web/serverfarms",
"name": "[variables('appServicePlanName')]",
"location": "[variables('location')]",
"sku": {
"name": "[parameters('sku')]"
},
"properties": {
"name": "[variables('appServicePlanName')]"
}
},
//App Service
{
"type": "Microsoft.Web/sites",
"apiVersion": "2018-11-01",
"name": "[parameters('webAppName')]",
"location": "[variables('location')]",
"kind": "app",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
],
"properties": {
"enabled": true,
"hostNameSslStates": [
{
"name": "[concat(parameters('webAppName'),'.azurewebsites.net')]",
"sslState": "Disabled",
"hostType": "Standard"
},
{
"name": "[concat(parameters('webAppName'),'.scm.azurewebsites.net')]",
"sslState": "Disabled",
"hostType": "Repository"
}
],
"reserved": false,
"isXenon": false,
"hyperV": false,
"siteConfig": {},
"scmSiteAlsoStopped": false,
"clientAffinityEnabled": true,
"clientCertEnabled": false,
"hostNamesDisabled": false,
"containerSize": 0,
"dailyMemoryTimeQuota": 0,
"httpsOnly": false,
"redundancyMode": "None"
}
},
{
"type": "Microsoft.Web/sites/config",
"apiVersion": "2018-11-01",
"name": "[concat(parameters('webAppName'), '/web')]",
"location": "[variables('location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', parameters('webAppName'))]"
],
"properties": {
"numberOfWorkers": 1,
"defaultDocuments": [
"Default.htm",
"Default.html",
"Default.asp",
"index.htm",
"index.html",
"iisstart.htm",
"default.aspx",
"index.php",
"hostingstart.html"
],
"netFrameworkVersion": "v2.0",
"requestTracingEnabled": false,
"remoteDebuggingEnabled": false,
"httpLoggingEnabled": false,
"logsDirectorySizeLimit": 35,
"detailedErrorLoggingEnabled": false,
"publishingUsername": "$AdAstraflexSurveyWebAppTest",
"azureStorageAccounts": {},
"scmType": "None",
"use32BitWorkerProcess": true,
"webSocketsEnabled": false,
"alwaysOn": false,
"managedPipelineMode": "Integrated",
"virtualApplications": [
{
"virtualPath": "/",
"physicalPath": "site\\wwwroot",
"preloadEnabled": false
}
],
"loadBalancing": "LeastRequests",
"experiments": {
"rampUpRules": []
},
"autoHealEnabled": false,
"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": false,
"minTlsVersion": "1.2",
"ftpsState": "AllAllowed",
"reservedInstanceCount": 0
}
},
{
"type": "Microsoft.Web/sites/hostNameBindings",
"apiVersion": "2018-11-01",
"name": "[concat(parameters('webAppName'), '/', parameters('webAppName'), '.azurewebsites.net')]",
"location": "[variables('location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', parameters('webAppName'))]"
],
"properties": {
"siteName": "AdAstraflexSurveyWebAppTest",
"hostNameType": "Verified"
}
},
//Storage Accounts
{
"name": "[parameters('storageAccountName')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2020-08-01-preview",
"sku":
{
"name": "Standard_RAGRS",
"tier": "Standard"
},
"kind": "StorageV2",
"location": "[variables('location')]",
"properties":
{
"minimumTlsVersion": "TLS1_2",
"allowBlobPublicAccess": true,
"networkAcls":
{
"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"
}
}
]
}
解决方案
我试过你的模板,对我来说效果很好。您可以稍后使用新资源组或以下模板尝试。
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"webAppName": {
"type": "String",
"metadata": {
"description": "The App Service name."
}
},
"sku": {
"type": "string",
"defaultValue": "F1",
"metadata": {
"description": "The SKU of App Service Plan."
}
},
"storageAccountName": {
"type": "string",
"metadata": {
"description": "The Storage Account name."
}
}
},
"variables": {
"appServicePlanName": "[concat('AppServicePlan-', parameters('webAppName'))]",
"location": "[resourceGroup().location]"
},
"resources": [
//App services plan
{
"apiVersion": "2020-06-01",
"type": "Microsoft.Web/serverfarms",
"name": "[variables('appServicePlanName')]",
"location": "[variables('location')]",
"sku": {
"name": "[parameters('sku')]"
},
"properties": {
"name": "[variables('appServicePlanName')]"
}
},
//App Service
{
"type": "Microsoft.Web/sites",
"apiVersion": "2018-11-01",
"name": "[parameters('webAppName')]",
"location": "[variables('location')]",
"kind": "app",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
],
"properties": {
"enabled": true,
"hostNameSslStates": [
{
"name": "[concat(parameters('webAppName'),'.azurewebsites.net')]",
"sslState": "Disabled",
"hostType": "Standard"
},
{
"name": "[concat(parameters('webAppName'),'.scm.azurewebsites.net')]",
"sslState": "Disabled",
"hostType": "Repository"
}
],
"reserved": false,
"isXenon": false,
"hyperV": false,
"siteConfig": {},
"scmSiteAlsoStopped": false,
"clientAffinityEnabled": true,
"clientCertEnabled": false,
"hostNamesDisabled": false,
"containerSize": 0,
"dailyMemoryTimeQuota": 0,
"httpsOnly": false,
"redundancyMode": "None"
}
},
{
"type": "Microsoft.Web/sites/config",
"apiVersion": "2018-11-01",
"name": "[concat(parameters('webAppName'), '/web')]",
"location": "[variables('location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', parameters('webAppName'))]"
],
"properties": {
"numberOfWorkers": 1,
"defaultDocuments": [
"Default.htm",
"Default.html",
"Default.asp",
"index.htm",
"index.html",
"iisstart.htm",
"default.aspx",
"index.php",
"hostingstart.html"
],
"netFrameworkVersion": "v2.0",
"requestTracingEnabled": false,
"remoteDebuggingEnabled": false,
"httpLoggingEnabled": false,
"logsDirectorySizeLimit": 35,
"detailedErrorLoggingEnabled": false,
"publishingUsername": "$AdAstraflexSurveyWebAppTest",
"azureStorageAccounts": {},
"scmType": "None",
"use32BitWorkerProcess": true,
"webSocketsEnabled": false,
"alwaysOn": false,
"managedPipelineMode": "Integrated",
"virtualApplications": [
{
"virtualPath": "/",
"physicalPath": "site\\wwwroot",
"preloadEnabled": false
}
],
"loadBalancing": "LeastRequests",
"experiments": {
"rampUpRules": []
},
"autoHealEnabled": false,
"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": false,
"minTlsVersion": "1.2",
"ftpsState": "AllAllowed",
"reservedInstanceCount": 0
}
},
{
"type": "Microsoft.Web/sites/hostNameBindings",
"apiVersion": "2018-11-01",
"name": "[concat(parameters('webAppName'), '/', parameters('webAppName'), '.azurewebsites.net')]",
"location": "[variables('location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', parameters('webAppName'))]"
],
"properties": {
"siteName": "AdAstraflexSurveyWebAppTest",
"hostNameType": "Verified"
}
},
//Storage Accounts
{
"name": "[parameters('storageAccountName')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2020-08-01-preview",
"sku":
{
"name": "Standard_RAGRS",
"tier": "Standard"
},
"kind": "StorageV2",
"location": "[variables('location')]",
"properties":
{
"minimumTlsVersion": "TLS1_2",
"allowBlobPublicAccess": true,
"networkAcls":
{
"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"
}
}
]
}
推荐阅读
- delphi - THTTPClient 在几个连续请求后阻塞
- sql - 当我从大表中检索非索引列时,SQL Server 会查找 PK
- qgis - 来自 QGIS 元数据文件的 Google ImportXML
- react-native - react-native-tab-view 的 Jest 单元测试
- angular - Angular 应用程序仅在 IE11 上引发语法错误
- java - 为什么在一个循环中加入所有线程与一次启动和加入一个线程不同?
- arrays - Ruby classArray[index].class_method 不在不同的范围内工作
- asp.net-mvc-5 - 预定义的 MVC ApplicationDbContext 是否应该移动到不同的层、域或存储?
- python - 如何在python中将n维数组从形状(1600,105)重塑为形状(1600,14,105)?另外,如何将列从一个复制到另一个?
- python - 如何从 Python 进程登录到 Kubernetes 容器日志