When deploying the following the final deployment always fails with resourcegroup not found. The previous for will work.
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appBaseName": {
"type": "string",
"metadata": {
"description": "Name of the application. Used in the name of resources."
},
"minLength": 5,
"maxLength": 12,
"defaultValue": "[deployment().name]"
},
"tenantId": {
"type": "string",
"defaultValue": "[subscription().tenantId]",
"metadata": {
"description": "Tenant ID for deployment"
}
},
"location": {
"type": "string",
"defaultValue": "eastus2",
"metadata": {
"description": "Location for deployment"
}
},
"administratorLogin": {
"type": "string",
"metadata": {
"description": "The administrator username of the SQL logical server.",
"defaultValue": "admingod"
}
},
"administratorLoginPassword": {
"type": "securestring",
"metadata": {
"description": "The administrator password of the SQL logical server.",
"defaultValue": "Passw0rd10s"
}
}
},
"variables": {
"AppInsightsName": "[concat(parameters('appBaseName'), '-AppInsights')]",
"AppServicePlanName": "[concat(parameters('appBaseName'), '-ASP')]",
"SQLServer": "[concat(parameters('appBaseName'), '-sqlserver')]",
"SQLDB": "[concat(parameters('appBaseName'), '-sqldb')]",
"WebAppName": "[concat(parameters('appBaseName'), '-web')]",
"ResourceGroupName": "[concat(parameters('appBaseName'), '-rg')]",
"storageAccountName": "[concat('stg',parameters('appBaseName'))]",
"storageAccountId": "[concat(subscription().id,'/resourcegroups/', variables('ResourceGroupName'),'/providers/','Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
"functionName": "[concat(parameters('appBaseName'),'-fn')]",
"KeyVaultName": "[concat(parameters('appBaseName'), '-kv')]",
"appInsightsId": "[concat(subscription().id,'/resourcegroups/', variables('ResourceGroupName'),'/providers/','Microsoft.Insights/components/', variables('AppInsightsName'))]",
"ResourceGroupId": "[resourceId('Microsoft.Resources/resourceGroups/', variables('ResourceGroupName'))]"
},
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"apiVersion": "2019-10-01",
"name": "[variables('ResourceGroupName')]",
"location": "[parameters('location')]",
"properties": {}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2017-05-10",
"name": "[concat(deployment().name,'-KeyVault')]",
"resourceGroup": "[variables('ResourceGroupName')]",
"dependsOn": [
"[resourceId('Microsoft.Resources/resourceGroups/', variables('ResourceGroupName'))]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"name": "[variables('KeyVaultName')]",
"type": "Microsoft.KeyVault/vaults",
"apiVersion": "2016-10-01",
"location": "[parameters('location')]",
"tags": {
"displayName": "[variables('KeyVaultName')]"
},
"properties": {
"enabledForDeployment": true,
"enabledForTemplateDeployment": true,
"enabledForDiskEncryption": true,
"tenantId": "[parameters('tenantId')]",
"accessPolicies": [
],
"sku": {
"name": "standard",
"family": "A"
}
}
}
],
"outputs": {}
}
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2017-05-10",
"name": "[concat(deployment().name,'-SQL')]",
"resourceGroup": "[variables('ResourceGroupName')]",
"dependsOn": [
"[resourceId('Microsoft.Resources/resourceGroups/', variables('ResourceGroupName'))]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"type": "Microsoft.Sql/servers",
"apiVersion": "2019-06-01-preview",
"name": "[variables('SQLServer')]",
"location": "[parameters('location')]",
"properties": {
"administratorLogin": "[parameters('administratorLogin')]",
"administratorLoginPassword": "[parameters('administratorLoginPassword')]"
},
"resources": [
{
"type": "databases",
"apiVersion": "2019-06-01-preview",
"name": "[variables('SQLDB')]",
"sku": {
"name": "Standard",
"tier": "Standard"
},
"location": "[parameters('location')]",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"edition": "Basic",
"maxSizeBytes": "1073741824",
"requestedServiceObjectiveName": "Basic"
},
"dependsOn": [
"[variables('SQLServer')]"
]
}
]
}
],
"outputs": {}
}
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2017-05-10",
"name": "[concat(deployment().name,'-App')]",
"resourceGroup": "[variables('ResourceGroupName')]",
"dependsOn": [
"[resourceId('Microsoft.Resources/resourceGroups/', variables('ResourceGroupName'))]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"apiVersion": "2019-08-01",
"type": "Microsoft.Web/serverfarms",
"name": "[variables('AppServicePlanName')]",
"location": "[parameters('location')]",
"properties": {
"name": "[variables('AppServicePlanName')]"
},
"sku": {
"name": "F1",
"capacity": 1
}
},
{
"apiVersion": "2019-08-01",
"type": "Microsoft.Web/sites",
"name": "[variables('WebAppName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[concat(subscription().id,'/resourcegroups/', variables('ResourceGroupName'), '/providers/Microsoft.Web/serverfarms/', variables('AppServicePlanName'))]"
],
"properties": {
"name": "[variables('WebAppName')]",
"serverFarmId": "[concat(subscription().id,'/resourcegroups/', variables('ResourceGroupName'), '/providers/Microsoft.Web/serverfarms/', variables('AppServicePlanName'))]"
}
}
],
"outputs": {}
}
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2017-05-10",
"name": "[concat(deployment().name,'-FuncApp')]",
"resourceGroup": "[variables('ResourceGroupName')]",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-04-01",
"location": "[parameters('location')]",
"name": "[variables('storageAccountName')]",
"sku": {
"name": "Standard_RAGRS"
},
"kind": "StorageV2",
"properties": {}
},
{
"name":"[variables('AppInsightsName')]",
"type":"Microsoft.Insights/components",
"apiVersion":"2015-05-01",
"location":"[parameters('location')]",
"kind":"web",
"properties":{
"application_Type":"web",
"ApplicationId": "[variables('appInsightsName')]"
}
},
{
"name": "[variables('functionName')]",
"type": "Microsoft.Web/sites",
"apiVersion": "2018-11-01",
"location": "[parameters('location')]",
"kind": "functionapp",
"properties": {
"serverFarmId": "[concat(subscription().id,'/resourcegroups/', variables('ResourceGroupName'), '/providers/Microsoft.Web/serverfarms/', variables('AppServicePlanName'))]",
"siteConfig": {
"appSettings": [
{
"name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=',variables('storageAccountName'),';AccountKey=',listKeys(variables('storageAccountId'),'2019-06-01').keys[0].value)]"
},
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference(concat(subscription().id,'/resourcegroups/', variables('ResourceGroupName'), '/providers/Microsoft.Insights/components/', variables('AppInsightsName')), '2015-05-01').InstrumentationKey]"
},
{
"name": "AzureWebJobsStorage",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]"
},
{
"name": "AzureWebJobsDashboard",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]"
},
{
"name": "WEBSITE_CONTENTSHARE",
"value": "[toLower('functionName')]"
},
{
"name": "FUNCTIONS_EXTENSION_VERSION",
"value": "~2"
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "dotnet"
}
]
}
}
}
],
"outputs": {}
}
}
}
],
"outputs": {}
}
I receive the following:
cli.azure.cli.core.util : Deployment failed. Correlation ID: 0cca46d7-6342-4a87-8f94-c12ba9b595f9. {
"error": {
"code": "ResourceGroupNotFound",
"message": "Resource group 'devcloud15-rg' could not be found."
}
}
Deployment failed. Correlation ID: 0cca46d7-6342-4a87-8f94-c12ba9b595f9. {
"error": {
"code": "ResourceGroupNotFound",
"message": "Resource group 'devcloud15-rg' could not be found."
}
}
I'm not sure why I'm receiving this error message if all other resources are deployed to the resource but the last deployment. I'm not sure if the listkeys function is causing the error with the deployment due to some dependency.
I changed the code to
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appBaseName": {
"type": "string",
"metadata": {
"description": "Name of the application. Used in the name of resources."
},
"minLength": 5,
"maxLength": 12
},
"tenantId": {
"type": "string",
"defaultValue": "[subscription().tenantId]",
"metadata": {
"description": "Tenant ID for deployment"
}
},
"location": {
"type": "string",
"defaultValue": "eastus2",
"metadata": {
"description": "Location for deployment"
}
},
"administratorLogin": {
"type": "string",
"metadata": {
"description": "The administrator username of the SQL logical server.",
"defaultValue": "admingod"
}
},
"administratorLoginPassword": {
"type": "securestring",
"metadata": {
"description": "The administrator password of the SQL logical server.",
"defaultValue": "Passw0rd10s"
}
}
},
"variables": {
"AppInsightsName": "[concat(parameters('appBaseName'), '-AppInsights')]",
"AppServicePlanName": "[concat(parameters('appBaseName'), '-ASP')]",
"SQLServer": "[concat(parameters('appBaseName'), '-sqlserver')]",
"SQLDB": "[concat(parameters('appBaseName'), '-sqldb')]",
"WebAppName": "[concat(parameters('appBaseName'), '-web')]",
"ResourceGroupName": "[concat(parameters('appBaseName'), '-rg')]",
"storageAccountName": "[concat('stg',parameters('appBaseName'))]",
"storageAccountId": "[concat(subscription().id,'/resourcegroups/', variables('ResourceGroupName'),'/providers/','Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
"functionName": "[concat(parameters('appBaseName'),'-fn')]",
"KeyVaultName": "[concat(parameters('appBaseName'), '-kv')]",
"ResourceGroupId": "[resourceId('Microsoft.Resources/resourceGroups/', variables('ResourceGroupName'))]"
},
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"apiVersion": "2019-10-01",
"name": "[variables('ResourceGroupName')]",
"location": "[parameters('location')]",
"properties": {}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2017-05-10",
"name": "[concat(parameters('appBaseName'),'-Storage')]",
"resourceGroup": "[variables('ResourceGroupName')]",
"dependsOn": [
"[resourceId('Microsoft.Resources/resourceGroups/', variables('ResourceGroupName'))]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-04-01",
"location": "[parameters('location')]",
"name": "[variables('storageAccountName')]",
"sku": {
"name": "Standard_RAGRS"
},
"kind": "StorageV2",
"properties": {}
}
],
"outputs": {}
}
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2017-05-10",
"name": "[concat(parameters('appBaseName'),'-AppInsights')]",
"resourceGroup": "[variables('ResourceGroupName')]",
"dependsOn": [
"[concat(parameters('appBaseName'),'-Storage')]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"name":"[variables('AppInsightsName')]",
"type":"Microsoft.Insights/components",
"apiVersion":"2015-05-01",
"location":"[parameters('location')]",
"kind":"web",
"properties":{
"application_Type":"web",
"ApplicationId": "[variables('appInsightsName')]"
}
}
],
"outputs": {}
}
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2017-05-10",
"name": "[concat(parameters('appBaseName'),'-KeyVault')]",
"resourceGroup": "[variables('ResourceGroupName')]",
"dependsOn": [
"[concat(parameters('appBaseName'),'-AppInsights')]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"name": "[variables('KeyVaultName')]",
"type": "Microsoft.KeyVault/vaults",
"apiVersion": "2016-10-01",
"location": "[parameters('location')]",
"tags": {
"displayName": "[variables('KeyVaultName')]"
},
"properties": {
"enabledForDeployment": true,
"enabledForTemplateDeployment": true,
"enabledForDiskEncryption": true,
"tenantId": "[parameters('tenantId')]",
"accessPolicies": [
],
"sku": {
"name": "standard",
"family": "A"
}
}
}
],
"outputs": {}
}
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2017-05-10",
"name": "[concat(parameters('appBaseName'),'-SQL')]",
"resourceGroup": "[variables('ResourceGroupName')]",
"dependsOn": [
"[concat(parameters('appBaseName'),'-KeyVault')]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"type": "Microsoft.Sql/servers",
"apiVersion": "2019-06-01-preview",
"name": "[variables('SQLServer')]",
"location": "[parameters('location')]",
"properties": {
"administratorLogin": "[parameters('administratorLogin')]",
"administratorLoginPassword": "[parameters('administratorLoginPassword')]"
},
"resources": [
{
"type": "databases",
"apiVersion": "2019-06-01-preview",
"name": "[variables('SQLDB')]",
"sku": {
"name": "Standard",
"tier": "Standard"
},
"location": "[parameters('location')]",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"edition": "Basic",
"maxSizeBytes": "1073741824",
"requestedServiceObjectiveName": "Basic"
},
"dependsOn": [
"[variables('SQLServer')]"
]
}
]
}
],
"outputs": {}
}
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2017-05-10",
"name": "[concat(parameters('appBaseName'),'-App')]",
"resourceGroup": "[variables('ResourceGroupName')]",
"dependsOn": [
"[concat(parameters('appBaseName'),'-SQL')]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"apiVersion": "2019-08-01",
"type": "Microsoft.Web/serverfarms",
"name": "[variables('AppServicePlanName')]",
"location": "[parameters('location')]",
"properties": {
"name": "[variables('AppServicePlanName')]"
},
"sku": {
"name": "F1",
"capacity": 1
}
},
{
"apiVersion": "2019-08-01",
"type": "Microsoft.Web/sites",
"name": "[variables('WebAppName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[concat(subscription().id,'/resourcegroups/', variables('ResourceGroupName'), '/providers/Microsoft.Web/serverfarms/', variables('AppServicePlanName'))]"
],
"properties": {
"name": "[variables('WebAppName')]",
"serverFarmId": "[concat(subscription().id,'/resourcegroups/', variables('ResourceGroupName'), '/providers/Microsoft.Web/serverfarms/', variables('AppServicePlanName'))]"
}
}
],
"outputs": {}
}
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2017-05-10",
"name": "[concat(parameters('appBaseName'),'-FuncApp')]",
"resourceGroup": "[variables('ResourceGroupName')]",
"dependsOn": [
"[concat(parameters('appBaseName'),'-AppInsights')]",
"[concat(parameters('appBaseName'),'-Storage')]",
"[concat(parameters('appBaseName'),'-App')]",
"[resourceId('Microsoft.Resources/resourceGroups/', variables('ResourceGroupName'))]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"name": "[variables('functionName')]",
"type": "Microsoft.Web/sites",
"apiVersion": "2018-11-01",
"location": "[parameters('location')]",
"kind": "functionapp",
"properties": {
"serverFarmId": "[concat(subscription().id,'/resourcegroups/', variables('ResourceGroupName'), '/providers/Microsoft.Web/serverfarms/', variables('AppServicePlanName'))]",
"siteConfig": {
"appSettings": [
{
"name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]"
},
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference(concat(subscription().id,'/resourcegroups/', variables('ResourceGroupName'), '/providers/Microsoft.Insights/components/', variables('AppInsightsName')), '2015-05-01').InstrumentationKey]"
},
{
"name": "AzureWebJobsStorage",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]"
},
{
"name": "AzureWebJobsDashboard",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]"
},
{
"name": "WEBSITE_CONTENTSHARE",
"value": "[toLower('functionName')]"
},
{
"name": "FUNCTIONS_EXTENSION_VERSION",
"value": "~2"
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "dotnet"
}
]
}
}
}
],
"outputs": {}
}
}
}
],
"outputs": {}
}
I will get the same error as before
"error": {
"code": "ResourceGroupNotFound",
"message": "Resource group 'devcloud4-rg' could not be found."
}
}
Now as soon as it fails and I deploy again, it succeeds. It will fail on the FuncApp Deployment. I'm not sure if there is a race condition or something is not fully up with previous services.
I'm not sure if there is a way to put a depends on the instrumentation key and storage key for the app Function reference under the service Plan.
You are getting that error because in the last resource(line 209) you are missing the dependsOn that you have in the previous resources.
"dependsOn": [
"[resourceId('Microsoft.Resources/resourceGroups/', variables('ResourceGroupName'))]"
],
So the deployment try to create the Microsoft.Resources/deployments without waiting for the ResourceGroup to be created.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.