1
votes

I'm using ARM templates to create azure resources for my project. One of the applications is .NET 5.0 Rest API deployed as App Service with scheme as follows:

{
    "apiVersion": "2020-06-01",
    "name": "[variables('myWebsiteName')]",
    "type": "Microsoft.Web/sites",
    "location": "[resourceGroup().location]",
    "dependsOn": [
      "[resourceId('Microsoft.Web/serverFarms/', variables('hostingPlanName'))]",
      "[resourceId('microsoft.insights/components/', variables('myWebsiteName'))]"
    ],
    "tags": {
      "environment": "[parameters('environment')]",
      "[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', variables('hostingPlanName'))]": "empty",
      "displayName": "MyWebsite"
    },
    "properties": {
      "name": "[variables('myWebsiteName')]",
      "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
      "siteConfig": {
        "netFrameworkVersion": "v5.0",
        "appSettings": [
          {
            "name": "APPINSIGHTS_INSTRUMENTATIONKEY",
            "value": "[reference(concat('microsoft.insights/components/', variables('myWebsiteName')), '2015-05-01').InstrumentationKey]"
          },
          {
            "name": "APPLICATIONINSIGHTS_CONNECTION_STRING",
            "value": "[reference(concat('microsoft.insights/components/', variables('myWebsiteName')), '2015-05-01').ConnectionString]"
          },
          {
            "name": "ApplicationInsightsAgent_EXTENSION_VERSION",
            "value": "~2"
          },
          {
            "name": "XDT_MicrosoftApplicationInsights_Mode",
            "value": "default"
          }
        ],
        "metadata": [
          {
            "name": "CURRENT_STACK",
            "value": "dotnet"
          }
        ]
      }
    }
 }

For deploy I use ARM template deployment task in incremental mode in Azure DevOps.

After I deploy ARM template I can successfuly deploy my application to App Service and its working correctly. The problem is that if I re-deploy the same ARM template, then code from App Service gets wiped out. There is no code on the server, and entering website address shows only this sentence:

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

How can I deploy my ARM template so the App Service stays intact if there weren't any changes in its template? It behaves correctly for another App Services, but this one always gets wiped out, even though ARM template doesn't change.

2
Hi @Peace, How are things going? Have you tried the suggestion in my answer? Is it helpful to you? Please try it, and any progress, feel free to tell me.Bright Ran-MSFT
Local machine deploys results in the same behavior. The suggestion about file not present is pretty obvious to me - code is being removed, so the web.config is not there. But the problem is that the code is wiped out, not a missconfigured web.config.Peace
@peace did you find a solution for this? I have the same issueB Z

2 Answers

1
votes

Below worked for me. My www was getting removed during arm deployment, even though the app service was declared in the template.

Adding this app setting solved the problem:

{ "name": "WEBSITE_RUN_FROM_PACKAGE", "value": "1" }

hat tip goes to: https://stackoverflow.com/a/53644221/25020

-1
votes

This error suggests that the file you are looking is not present on the server or web.config file is not configured properly.

You can reference to the following articles to try setting up a web.config for your template:

In addition, you also can try to deploy your template from your local machine to see if the same problem occurs. For example, using Azure CLI to deploy ARM templates.