azureazure-devopsazure-web-app-serviceazure-resource-managerazure-yaml-pipelines

AzureRmWebAppDeployment@4 tries to deploy to a wrong URL to Linux app plan


I am creating a new Azure devops pipeline to deploy to a to Linux app plan and I use YAML scripts for this.

I create a web site with an ARM template and the part of it to create the slot is this YAML calls an ARM template:

        - task: AzureResourceGroupDeployment@2
          displayName: 'Create APP Service'
          inputs:
            azureSubscription: '${{ parameters.AzureSub }}'
            resourceGroupName: $(Environment.Name)-WebAppResGrp
            location: '${{ parameters.Location }}'
            csmFile: '$(Pipeline.Workspace)/ARM_Templates/Templates/WebApp.Template.json'
            csmParametersFile: '$(Pipeline.Workspace)/ARM_Templates/WebApp.$(Environment.Name).json'

And this is the part of ARM that creates the web app:

    {
    "apiVersion": "2018-11-01",
    "name": "[parameters('webSiteName')]",
    "type": "Microsoft.Web/sites",
    .....,
    "resources": [
    {
          "condition": "[parameters('slotsEnabled')]",
          "type": "slots",
          "apiVersion": "2015-08-01",
          "name": "staging",
          "tags": {
            "displayName": "Staging Slot"
          },
          "location": "[resourceGroup().location]",
          "dependsOn": [
            "[resourceId('Microsoft.Web/sites', parameters('webSiteName'))]"
          ],
          "properties": {
          },
          "resources": []
        }
    ]

The app is created OK, with staging slot. However, when I try to deploy there from yaml with this code

        - task: AzureRmWebAppDeployment@4
          displayName: 'Deploy App to Staging slot'
          inputs:
            azureSubscription: '${{ parameters.AzureSub }}'
            WebAppName: '$(Environment.Name)-Lab1'
            deployToSlotOrASE: true
            ResourceGroupName: $(Environment.Name)-WebAppResGrp
            SlotName: staging
            packageForLinux: '$(Pipeline.Workspace)/App/source'
            enableCustomDeployment: true
            TakeAppOfflineFlag: false
            RemoveAdditionalFilesFlag: true
            ExcludeFilesFromAppDataFlag: false

I have this error:

    Could not connect to the remote computer ("<environment name>-<app name>-staging.scm.azurewebsites.net"). On the remote computer, make sure that Web Deploy is installed and that the required process ("Web Management Service") is started.  Learn more at: https://go.microsoft.com/fwlink/?LinkId=221672#ERROR_DESTINATION_NOT_REACHABLE.
    Error: The remote server returned an error: (404) Not Found.

and when I go to the slot in the Azure portal, its URL is <environment name>-<app name>-staging.azurewebsites.net - no .scm before ".azurewebsites.net"

I am at a stage where I can fix either deployment slot URL or the url to deploy the code, but I cannot find how to specify either.

I want to avoid specifying unique suffix names. I will do it if I have to, but it will be the last resort.

Why the URLs do not match each other and what way would be the best to fix it?

Edited: I missed a crucial piece of information, the OS the app is deployed is Linux.


Solution

  • I have a Azure Web App created on Linux OS.

    enter image description here

    When I set the AzureRmWebAppDeployment@4 task with the same configuration like as yours, I can the same ERROR_DESTINATION_NOT_REACHABLE error.

    - task: AzureRmWebAppDeployment@4
      inputs:
        ConnectionType: 'AzureRM'
        azureSubscription: 'myArmConnection'
        WebAppName: 'BriRanApp01'
        deployToSlotOrASE: true
        ResourceGroupName: 'myResourceGroup'
        SlotName: 'staging'
        packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'
        enableCustomDeployment: true
        TakeAppOfflineFlag: false
        RemoveAdditionalFilesFlag: true
        ExcludeFilesFromAppDataFlag: false
    

    enter image description here

    After I changed the configuration like as below, the error gets fixed.

    - task: AzureRmWebAppDeployment@4
      inputs:
        ConnectionType: 'AzureRM'
        azureSubscription: 'myArmConnection'
        appType: 'webAppLinux'
        WebAppName: 'BriRanApp01'
        deployToSlotOrASE: true
        ResourceGroupName: 'myResourceGroup'
        SlotName: 'staging'
        packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'
        enableCustomDeployment: true
        TakeAppOfflineFlag: false
        RemoveAdditionalFilesFlag: true
        ExcludeFilesFromAppDataFlag: false
    

    enter image description here

    The reason of the error is that if you omit the 'appType' (App Service type) option on the AzureRmWebAppDeployment@4 task, it will apply the default value 'webApp' (Web App on Windows) this is not consistent with the actual app type 'webAppLinux' (Web App on Linux).

    enter image description here

    So, if the actual app type is not 'webApp', you need to use the 'appType' option to explicitly specify the correct one on the task.