Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.26k stars 3.86k forks source link

After running New-AzResourceGroupDeployment against an existing app service, the code on app service is gone #21226

Open larry-lau opened 1 year ago

larry-lau commented 1 year ago

Description

Every time I run New-AzResourceGroupDeployment on an existing app service, the code on the app service seems to be wiped. I have to publish my dotnet code again after each deployment. Is there a way to keep the code between ARM deployment?

Script or Debug output

No response

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.9
PSEdition                      Core
GitCommitId                    7.2.9
OS                             Microsoft Windows 10.0.22000
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.9.1                 Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzConte…
Script     4.6.0                 Az.KeyVault                         {Add-AzKeyVaultCertificate, Add-AzKeyVaultCertifi…
Script     6.0.1                 Az.Resources                        {Export-AzResourceGroup, Export-AzTemplateSpec, G…
Script     4.7.0                 Az.Storage                          {Add-AzRmStorageContainerLegalHold, Add-AzStorage…

PS

Error output

No response

isra-fel commented 1 year ago

Thanks for reporting Larry 👍 Let me route this to the ARM team. At the meantime, could you share the template and the PowerShell script to start the deployment? (Be sure to remove sensitive information).

ghost commented 1 year ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @satyavel, @apclouds.

Issue Details
### Description Every time I run New-AzResourceGroupDeployment on an existing app service, the code on the app service seems to be wiped. I have to publish my dotnet code again after each deployment. Is there a way to keep the code between ARM deployment? ### Script or Debug output _No response_ ### Environment data ```PowerShell Name Value ---- ----- PSVersion 7.2.9 PSEdition Core GitCommitId 7.2.9 OS Microsoft Windows 10.0.22000 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0 ``` ### Module versions ```PowerShell ModuleType Version PreRelease Name ExportedCommands ---------- ------- ---------- ---- ---------------- Script 2.9.1 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzConte… Script 4.6.0 Az.KeyVault {Add-AzKeyVaultCertificate, Add-AzKeyVaultCertifi… Script 6.0.1 Az.Resources {Export-AzResourceGroup, Export-AzTemplateSpec, G… Script 4.7.0 Az.Storage {Add-AzRmStorageContainerLegalHold, Add-AzStorage… PS ``` ### Error output _No response_
Author: larry-lau
Assignees: -
Labels: `Service Attention`, `question`, `ARM - Templates`, `customer-reported`
Milestone: -
larry-lau commented 1 year ago

Here is my template and powershell command

{
  "name": "[variables('adminCenterAppName')]",
  "type": "Microsoft.Web/sites",
  "apiVersion": "2022-03-01",
  "location": "[parameters('location')]",
  "dependsOn": [
    "[resourceId(parameters('hostingPlanGroup'), 'Microsoft.Web/serverfarms', parameters('hostingPlanName'))]"
  ],
  "identity": {
    "type": "UserAssigned",
    "userAssignedIdentities": {
      "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', variables('managedIdentityName'))]": {}
    }
  },
  "properties": {
    "serverFarmId": "[resourceId(parameters('hostingPlanGroup'), 'Microsoft.Web/serverfarms', parameters('hostingPlanName'))]",
    "httpsOnly": true,
    "siteConfig": {
      "alwaysOn": true,
      "appSettings": [            
      ]
    }
  },
  "tags": {
    "displayName": "AppService"
  }
},
{
  "type": "Microsoft.Web/sites/config",
  "apiVersion": "2022-03-01",
  "name": "[concat(variables('adminCenterAppName'), '/web')]",
  "location": "[parameters('location')]",
  "dependsOn": [
    "[resourceId('Microsoft.Web/sites', variables('adminCenterAppName'))]"
  ],
  "tags": {
    "displayName": "AppService Config"
  },
  "properties": {
    "numberOfWorkers": 1,
    "netFrameworkVersion": "v7.0",
    "use32BitWorkerProcess": false,
    "webSocketsEnabled": false,
    "alwaysOn": true,
    "http20Enabled": true,
    "minTlsVersion": "1.2"
  }
}

New-AzResourceGroupDeployment -Name ((Get-ChildItem $TemplateFile).BaseName + '-' + ((Get-Date).ToUniversalTime()).ToString('MMdd-HHmm')) -ResourceGroupName $ResourceGroupName -TemplateFile $TemplateFile -TemplateParameterFile $TemplateParametersFile @OptionalParameters -Force -Verbose -ErrorVariable ErrorMessages