Azure / Azure/azure-rest-api-specs

webapp:New-AzResourceGroupDeployment for web site with slot fails if template contains "cloningInfo"

Open
#7,276 13 comments 0 reactions 0 assignees View on GitHub
App Services customer-reported Service Attention
Dominant language
TypeSpec
Stars
3.1k
Forks
5.9k
Avg merge
3d 2h
Merged PRs (30d)
424

Description

### Description
I'm trying to deploy a web app with two slots (production, deploytarget). Everything works fine the first time, but subsequent runs with the web app already present fail with an error indicating the site already exists. I was under the impression that ARM templates should always be able to run even if the resources already exist? If not is there a quick way to tell ARM that it should not touch the slot if it exists?

The problem goes away if I remove the "cloningInfo" options from the template. It appears there is a problem with cloning onto an existing app service.
```
"cloningInfo": {
"sourceWebAppId": "[resourceId('Microsoft.Web/sites', variables('webAppName'))]",
"overwrite": true
}
```

### Script/Steps for Reproduction
```powershell
New-AzResourceGroupDeployment # with provided template
```
This is the template that is used:
```
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"environment": {
"type": "string",
"allowedValues": [
"devtest",
"test",
"stag",
"prod"
]
},

"skuName": {
"type": "string",
"defaultValue": "S1"
},
"skuCapacity": {
"type": "int",
"defaultValue": 1
},

"nodeVersion": {
"type": "string",
"defaultValue": "10.6.0"
},

"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]"
},
"deployTargetSlotName": {
"type": "string",
"defaultValue": "deploytarget"
}
},
"variables": {
"appServiceName": "[concat('TestAppServiceName-ASP-', parameters('environment'))]",
"webAppName": "[concat('TestAppServiceName-APP-', parameters('environment'))]"
},
"resources": [
{
"name": "[variables('appServiceName')]",
"type": "Microsoft.Web/serverfarms",
"kind": "app",
"sku": {
"name": "[parameters('skuName')]",
"capacity": "[parameters('skuCapacity')]"
},
"apiVersion": "2016-09-01",
"location": "[parameters('location')]",
"scale": null,
"properties": {
"name": "[variables('appServiceName')]"
}
},
{
"name": "[variables('webAppName')]",
"type": "Microsoft.Web/sites",
"apiVersion": "2018-02-01",
"location": "[parameters('location')]",
"tags": {
"displayName": "[variables('webAppName')]"
},
"properties": {
"name": "[variables('webAppName')]",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServiceName'))]",
"clientAffinityEnabled": false,
"httpsOnly": true,
"siteConfig": {
"alwaysOn": true,
"phpVersion": ""
}
},
"dependsOn": [
"[variables('appServiceName')]"
],
"resources": [
{
"name": "[parameters('deployTargetSlotName')]",
"type": "slots",
"apiVersion": "2018-02-01",
"dependsOn": [
"[variables('webAppName')]"
],
"location": "[parameters('location')]",
"properties": {
"enabled": false,
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServiceName'))]",
"clientAffinityEnabled": false,
"httpsOnly": true,
"cloningInfo": {
"sourceWebAppId": "[resourceId('Microsoft.Web/sites', variables('webAppName'))]",
"overwrite": true
}
}
}
]
}
],
"outputs": {
"webappName": {
"type": "string",
"value": "[variables('webAppName')]"
}
}
}
```

### Module Version
```powershell
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 0.6.1 Az.Profile {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Connect-AzAccount...}
Script 0.6.1 Az.Storage {Add-AzRmStorageContainerLegalHold, Add-AzStorageAccountNetworkRule, Disable-AzStorageDeleteRetentionPolicy, Enable-AzStorageDeleteRetentionPolicy...}
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
Manifest 3.0.0.0 Microsoft.PowerShell.Security {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSignature...}
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Manifest 3.0.0.0 Microsoft.WSMan.Management {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, Enable-WSManCredSSP...}
Script 1.2 PSReadline {Get-PSReadlineKeyHandler, Get-PSReadlineOption, Remove-PSReadlineKeyHandler, Set-PSReadlineKeyHandler...}
```

### Environment Data
```powershell
Name Value
---- -----
PSVersion 5.1.17134.407
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17134.407
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
```

### Debug Output
```
13:23:59 - Resource Microsoft.Web/sites/slots 'TestAppServiceName-ASP-devtest/deploytarget' failed with message '{
"status": "Failed",
"error": {
"code": "ResourceDeploymentFailure",
"message": "The resource operation completed with terminal provisioning state 'Failed'.",
"details": [
{
"message": "Conflict\r\nDetail: Site with name TestAppServiceName-ASP-devtest(deploytarget) already exists.\r\nExtendedCode: 04008\r\n at Microsoft.Web.Hosting.Administration.Csm.Common.Clients.GeoClientBase.GetResponse[T](HttpWebRequest request, Boolean reThrowOnHostUnavailability, HttpStatusCode[]
supressLogForHttpCodes)\r\n at Microsoft.Web.Hosting.Administration.GeoScale.Sql.WebSiteCloneManager.StartSiteRestore(SiteClone clone, Operation cloneOperation)\r\n"
}
]
}
}'
```

Contributor guide

Open the contributing guide

Research direction

No repository file or test entry point is identified. Start by reproducing the first and subsequent deployments with New-AzResourceGroupDeployment and the supplied ARM template, focusing on the Microsoft.Web/sites/slots resource and its cloningInfo properties. Done means the existing slot can be redeployed without the reported conflict, or the API specification clearly documents the supported behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, powershell
Domain
api, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.