I'm doing the Microsoft tutorial "Create Multi-stage Pipeline", exercise "Promote to Dev Stage": https://learn.microsoft.com/en-us/learn/modules/create-multi-stage-pipeline/4-promote-dev
This involves creating an Azure App Service, in my case named "tailspin-space-game-web-dev-4960.azurewebsites.net", and a multi-stage pipeline in Azure DevOps to build a web application project and deploy it to the App Service.
When I go to run the pipeline the deployment stage fails with the following message in the log:
Error: Resource 'tailspin-space-game-web-dev-4960.azurewebsites.net' doesn't exist. Resource should exist before deployment.
I've copied and pasted the URL http://tailspin-space-game-web-dev-4960.azurewebsites.net into another browser window to confirm the App Service exists and is running (although it's currently just showing the default app page since I haven't been able to deploy my application to it).
My question is: How do I test the service connection in Azure DevOps that should connect to the App Service? Alternatively, how do I debug the issue?
I haven't been able to find anything online about this error, and the only debugging info from Microsoft is about errors in creating service connections, not using them. I also can't find anything about testing service connections - the only advice I've found is to run them in the pipeline, which is a bit circular since that is where the error is occurring.
I've turned on verbose logging on the pipeline. This is the log from the failing deployment task (blank line added to highlight where it's attempting to get connection details):
##[debug]system.culture=en-US
##[debug]check path : /home/vsts/work/_tasks/AzureWebApp_18bde28a-8172-45cb-b204-5cef1393dbb1/1.163.2/node_modules/azurermdeploycommon/module.json
##[debug]adding resource file: /home/vsts/work/_tasks/AzureWebApp_18bde28a-8172-45cb-b204-5cef1393dbb1/1.163.2/node_modules/azurermdeploycommon/module.json
##[debug]system.culture=en-US
##[debug]azureSubscription=5d6d337f-3ceb-4a1d-8077-79e8c462faaf
##[debug]appType=null
##[debug]deployToSlotOrASE=false
##[debug]customWebConfig=null
##[debug]appSettings=null
##[debug]startUpCommand=null
##[debug]configurationStrings=null
##[debug]resourceGroupName=null
##[debug]slotName=production
##[debug]appName=tailspin-space-game-web-dev-4960.azurewebsites.net
##[debug]customDeployFolder=null
##[debug]5d6d337f-3ceb-4a1d-8077-79e8c462faaf auth scheme = ServicePrincipal
##[debug]5d6d337f-3ceb-4a1d-8077-79e8c462faaf data subscriptionid = 7258ca03-764d-4d8a-94e2-1f12bcd06be1
##[debug]5d6d337f-3ceb-4a1d-8077-79e8c462faaf data subscriptionname = Visual Studio Premium with MSDN
##[debug]5d6d337f-3ceb-4a1d-8077-79e8c462faaf auth param serviceprincipalid = ***
##[debug]5d6d337f-3ceb-4a1d-8077-79e8c462faaf data environmentAuthorityUrl = https://login.windows.net/
##[debug]5d6d337f-3ceb-4a1d-8077-79e8c462faaf auth param tenantid = ***
##[debug]5d6d337f-3ceb-4a1d-8077-79e8c462faaf=https://management.azure.com/
##[debug]5d6d337f-3ceb-4a1d-8077-79e8c462faaf data environment = AzureCloud
##[debug]5d6d337f-3ceb-4a1d-8077-79e8c462faaf auth scheme = ServicePrincipal
##[debug]5d6d337f-3ceb-4a1d-8077-79e8c462faaf data msiclientId = undefined
##[debug]5d6d337f-3ceb-4a1d-8077-79e8c462faaf data activeDirectoryServiceEndpointResourceId = https://management.core.windows.net/
##[debug]5d6d337f-3ceb-4a1d-8077-79e8c462faaf data AzureKeyVaultServiceEndpointResourceId = https://vault.azure.net
##[debug]5d6d337f-3ceb-4a1d-8077-79e8c462faaf data AzureKeyVaultDnsSuffix = vault.azure.net
##[debug]5d6d337f-3ceb-4a1d-8077-79e8c462faaf auth param authenticationType = ***
##[debug]credentials spn endpoint
##[debug]5d6d337f-3ceb-4a1d-8077-79e8c462faaf auth param serviceprincipalkey = ***
##[debug]5d6d337f-3ceb-4a1d-8077-79e8c462faaf data EnableAdfsAuthentication = false
##[debug]{"subscriptionID":"7258ca03-764d-4d8a-94e2-1f12bcd06be1","subscriptionName":"Visual Studio Premium with MSDN","servicePrincipalClientID":"***","environmentAuthorityUrl":"https://login.windows.net/","tenantID":"***","url":"https://management.azure.com/","environment":"AzureCloud","scheme":"ServicePrincipal","activeDirectoryResourceID":"https://management.azure.com/","azureKeyVaultServiceEndpointResourceId":"https://vault.azure.net","azureKeyVaultDnsSuffix":"vault.azure.net","authenticationType":"***","servicePrincipalKey":***,"isADFSEnabled":false,"applicationTokenCredentials":{"clientId":"***","domain":"***","baseUrl":"https://management.azure.com/","authorityUrl":"https://login.windows.net/","activeDirectoryResourceId":"https://management.azure.com/","isAzureStackEnvironment":false,"authType":"***","secret":***,"isADFSEnabled":false}}
Got service connection details for Azure App Service:'tailspin-space-game-web-dev-4960.azurewebsites.net'
##[debug][POST]https://login.windows.net/***/oauth2/token/
##[debug][GET]https://management.azure.com/subscriptions/7258ca03-764d-4d8a-94e2-1f12bcd06be1/resources?$filter=resourceType EQ 'Microsoft.Web%2FSites' AND name EQ 'tailspin-space-game-web-dev-4960.azurewebsites.net'&api-version=2016-07-01
##[debug]Correlation ID from ARM api call response : 37546212-3807-41bf-8985-9c811d0f9c75
##[debug]Deployment Failed with Error: Error: Resource 'tailspin-space-game-web-dev-4960.azurewebsites.net' doesn't exist. Resource should exist before deployment.
##[debug]task result: Failed
##[error]Error: Resource 'tailspin-space-game-web-dev-4960.azurewebsites.net' doesn't exist. Resource should exist before deployment.
##[debug]Processed: ##vso[task.issue type=error;]Error: Resource 'tailspin-space-game-web-dev-4960.azurewebsites.net' doesn't exist. Resource should exist before deployment.
##[debug]Processed: ##vso[task.complete result=Failed;]Error: Resource 'tailspin-space-game-web-dev-4960.azurewebsites.net' doesn't exist. Resource should exist before deployment.
##[debug]Deployment failed
Found the issue. I was using the wrong appName in the AzureWebApp@1 task in the pipeline.
I didn't notice that the App Service name was slightly different from the name that appears in the URL.
App Service name: tailspin-space-game-web-dev-4960
Name in URL: tailspin-space-game-web-dev-4960.azurewebsites.net
I was using the name from the URL in the appName. I should have been using the App Service name.