I have an ARM template that has worked for many months and now reliably fails when deploying.
I have included an extract below.
The template clones an Azure App Service to another. Most of the time the destination AAS will already exist and will just be updated with the new code.
{
"type": "Microsoft.Web/sites",
"apiVersion": "2022-03-01",
"name": "[variables('website_name')]",
"location": "[parameters('resourceLocation')]",
"properties": {
"cloningInfo": {
"sourceWebAppId": "[format('/subscriptions/{0}/resourceGroups/xxxxxx/providers/Microsoft.Web/sites/xxxxx', parameters('subscriptionId'))]",
"sourceWebAppLocation": "North Europe",
"cloneSourceControl": false,
"cloneCustomHostNames": false,
"overwrite": true,
"appSettingsOverrides": {
"APPINSIGHTS_INSTRUMENTATIONKEY": "[reference('microsoft.insights/components/xxxxx', '2015-05-01').InstrumentationKey]",
"XDT_MicrosoftApplicationInsights_Mode": "default",
"ApplicationInsightsAgent_EXTENSION_VERSION": "~2",
"Azure_BlobStorage_EndPoint": "[format('https://{0}.blob.{1}/', variables('storageAccount_name'), environment().suffixes.storage)]",
"Azure_Search_ApiKey": "[variables('search_apiKey')]",
"Azure_Search_DocumentManagementSystemIndexName": "[format('{0}-dms-index', parameters('tenantPrefix'))]",
"Azure_Search_ServiceName": "xxxx",
"WebFarm_RunOnAzureWebsites": "true"
}
},
"serverFarmId": "[format('/subscriptions/{0}/resourcegroups/{1}/providers/Microsoft.Web/serverfarms/{2}', parameters('subscriptionId'), parameters('resourceGroupName'), variables('website_hostingPlanName'))]"
},
"dependsOn": [
"[resourceId('Microsoft.Sql/servers/databases', split(format('{0}/{1}', variables('database_serverName'), variables('database_name')), '/')[0], split(format('{0}/{1}', variables('database_serverName'), variables('database_name')), '/')[1])]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccount_name'))]",
"[resourceId('Microsoft.Resources/deploymentScripts', 'websiteCheckerDeploymentScript')]"
]
},
If the AAS already exists, I add overwrite: true to cloningInfo. This used to work but currently no longer works. If I run it without overwrite, it fails (as expected) with the same message about the resource already existing. The only way I have got around this is to delete the destination resource by hand, wait a few minutes and then run the template. This then works... kind of. It either works fine or fails due to some other internal azure failure about not finding the snapshot etc etc.
I have many instances to update and deleting them one at a time and running the script until it works is a total nightmare as it used to work just fine.