Azure Pipeline Deployment to App Service fails: "Resource doesn't exist. Resource should exist before deployment". But App Service DOES exist

Rasmus Østergård 21 Reputation points
2022-02-01T14:51:18.607+00:00

I have an azure pipeline that deploys 10 Azure Web app to the same Azure resource group.
9 of the apps are deployed, but one of the apps fails with this error in the pipeline:

Deployment Failed with Error: Error: Resource 'app-pricing-api-demo-company' doesn't exist. Resource should exist before deployment.

##[debug]appName=app-pricing-api-demo-company
##[debug]customDeployFolder=undefined
##[debug]eaf38771-121e-4488-a347-b121590db6d0 auth scheme = ServicePrincipal
##[debug]eaf38771-121e-4488-a347-b121590db6d0 data subscriptionid = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx
##[debug]eaf38771-121e-4488-a347-b121590db6d0 data subscriptionname = Pay-As-You-Go
##[debug]eaf38771-121e-4488-a347-b121590db6d0 auth param serviceprincipalid = ***
##[debug]eaf38771-121e-4488-a347-b121590db6d0 data environmentAuthorityUrl = https://login.windows.net/
##[debug]eaf38771-121e-4488-a347-b121590db6d0 auth param tenantid = ***
##[debug]eaf38771-121e-4488-a347-b121590db6d0=https://management.azure.com/
##[debug]eaf38771-121e-4488-a347-b121590db6d0 data environment = AzureCloud
##[debug]eaf38771-121e-4488-a347-b121590db6d0 auth scheme = ServicePrincipal
##[debug]eaf38771-121e-4488-a347-b121590db6d0 data msiclientId = undefined
##[debug]eaf38771-121e-4488-a347-b121590db6d0 data activeDirectoryServiceEndpointResourceId = https://management.core.windows.net/
##[debug]eaf38771-121e-4488-a347-b121590db6d0 data AzureKeyVaultServiceEndpointResourceId = https://vault.azure.net
##[debug]eaf38771-121e-4488-a347-b121590db6d0 data AzureKeyVaultDnsSuffix = vault.azure.net
##[debug]eaf38771-121e-4488-a347-b121590db6d0 auth param authenticationType = ***
##[debug]credentials spn endpoint
##[debug]eaf38771-121e-4488-a347-b121590db6d0 auth param serviceprincipalkey = ***
##[debug]eaf38771-121e-4488-a347-b121590db6d0 data EnableAdfsAuthentication = false
##[debug]{"subscriptionID":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx","subscriptionName":"Pay-As-You-Go","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:'app-pricing-api-demo-company'
##[debug][POST]https://login.windows.net/***/oauth2/token/
##[debug][GET]https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/resources?$filter=resourceType EQ 'Microsoft.Web%2FSites' AND name EQ 'app-pricing-api-demo-company'&api-version=2016-07-01
##[debug]Correlation ID from ARM api call response : a4ad608e-8921-4b1a-b668-25eaf4f51ec0
**##[debug]Deployment Failed with Error: Error: Resource 'app-pricing-api-demo-company' doesn't exist. Resource should exist before deployment.**
##[debug]task result: Failed
##[error]Error: Resource 'app-pricing-api-demo-company' doesn't exist. Resource should exist before deployment.
##[debug]Processed: ##vso[task.issue type=error;]Error: Resource 'app-pricing-api-demo-company' doesn't exist. Resource should exist before deployment.
##[debug]Processed: ##vso[task.complete result=Failed;]Error: Resource 'app-pricing-api-demo-company' doesn't exist. Resource should exist before deployment.
##[debug]Deployment failed
Finishing: Deploy Pricing API

What I have tried

Please advise on how to troubleshoot

Azure App Services
Azure App Services
A feature of Azure App Service used to create and deploy scalable, mission-critical web apps.
4,600 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 16,621 Reputation points Microsoft Employee
    2022-02-02T17:52:53.777+00:00

    Hi @Rasmus Østergård

    When you receive a message such as

    Deployment Failed with Error: Error: Resource 'app-pricing-api-demo-company' doesn't exist. Resource should exist before deployment.

    it usually points to the mapping (or profile) of the app service in the deployment pipeline doesn't exist. An app service can be created, a pipeline configured for that app service, later be removed, and recreated for you to end up in this state. Some other things I could check:

    • Verify the app service using either Azure CLI or REST API
    • Double check the service connection configured for your pipeline has the proper access to the app services you're deploying.

    ---
    EDIT 2022 Mar 14: To benefit the broader community; I'm updating the answer with the findings from offline discussions. It was determined your app service plan was running into high CPU utilization. You're utilizing a single app service plan to run your workloads and were performing terraform deployments when there was zero load on the plan. But due to previous CPU loads, there may not have been enough headroom for deployments. The resolve was to scale out/up your app service plan for more headroom.