Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource should exist before deployment. Cannot read property 'getApplicationURL' of undefined. #15532

Open
tomred-net opened this issue Nov 23, 2021 · 183 comments

Comments

@tomred-net
Copy link

Note

Issues in this repo are for tracking bugs, feature requests and questions for the tasks in this repo

For a list:
https://github.com/Microsoft/azure-pipelines-tasks/tree/master/Tasks

If you have an issue or request for the Azure Pipelines service, use developer community instead:

https://developercommunity.visualstudio.com/spaces/21/index.html )

Required Information

Entering this information will route you directly to the right team and expedite traction.

Question, Bug, or Feature?
Type: Bug

Enter Task Name:

  • AzureRmWebAppDeploymentV4 (AzureRMWebAppDeployment@4)

list here (V# not needed):
https://github.com/Microsoft/azure-pipelines-tasks/tree/master/Tasks

Environment

Issue Description

Azure Web App Deployment can't find existing Microsoft.Web/sites
##[debug]Deployment Failed with Error: Error: Resource '...xxxx...' doesn't exist. Resource should exist before deployment.
This appears to be because the query is case sensitive:
##[debug][GET]https://management.azure.com/subscriptions/a1dc7c64-6f29-4584-90a3-a65732d701af/resources?$filter=resourceType EQ 'Microsoft.Web%252FSites' AND name EQ 'request-to-pay-service'&api-version=2016-07-01
Microsoft.Web%252FSites >Microsoft.Web/Sites but the correct value (and the value that is in other deployment strings is Microsoft.Web/sites note the lower case s in sites.

[Include task name(s), screenshots and any other relevant details]

Task logs

##[debug]{"subscriptionID":"","subscriptionName":"","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","scopeLevel":"Subscription","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:'
'
##[debug][POST]https://login.windows.net/***/oauth2/token/
##[debug][GET]https://management.azure.com/subscriptions/***/resources?$filter=resourceType EQ 'Microsoft.Web%252FSites' AND name EQ ''&api-version=2016-07-01
##[debug]Correlation ID from ARM api call response : b79bdf30-6fd1-4ff5-97af-955641ac01b3
##[debug]Deployment Failed with Error: Error: Resource '
' doesn't exist. Resource should exist before deployment.
(node:1722) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'getApplicationURL' of undefined
at ContainerWebAppDeploymentProvider. (/home/vsts/work/_tasks/AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1/4.184.4/deploymentProvider/AzureRmWebAppDeploymentProvider.js:54:73)
##[debug]task result: Failed
at Generator.next ()
##[error]Error: Resource '***' doesn't exist. Resource should exist before deployment.
##[debug]Processed: ##vso[task.issue type=error;]Error: Resource 'request-to-pay-service' doesn't exist. Resource should exist before deployment.

Troubleshooting

Checkout how to troubleshoot failures and collect debug logs: https://docs.microsoft.com/en-us/vsts/build-release/actions/troubleshooting

Error logs

[Insert error from the logs here for a quick overview]

@v-ibshaik v-ibshaik added the environment:need-to-triage Issues need to be triage by environment-deployment team label Nov 23, 2021
@v-ibshaik
Copy link
Contributor

Hello tomred-net
Can you please confirm if the web site / app is already created ? The task expects the app should be pre-created.

Thanks

@tomred-net
Copy link
Author

tomred-net commented Nov 23, 2021

Hi, @v-ibshaik

The App Service Plan and App Services exist and can be seen when querying the az resource list. The query name matches the search name.

This is the cleaned up output:

==============================================================================
Task         : Azure App Service deploy
Description  : Deploy to Azure App Service a web, mobile, or API app using Docker, Java, .NET, .NET Core, Node.js, PHP, Python, or Ruby
Version      : 4.184.4
Author       : Microsoft Corporation
Help         : https://aka.ms/azureappservicetroubleshooting
==============================================================================
Got service connection details for Azure App Service:'request-to-pay-service'
##[error]Error: Resource 'request-to-pay-service' doesn't exist. Resource should exist before deployment.
(node:1689) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'getApplicationURL' of undefined

You will see the request that is failing is the filter resources by name and type. It is either the double escaping of the / in the Microsoft.Web%252FSites or if the query is case sensitive the use of S instead of s in sites as you can see the name matches the following result.

##[debug][GET]https://management.azure.com/subscriptions/.../resources?$filter=resourceType EQ 'Microsoft.Web%252FSites' AND name EQ 'request-to-pay-service'&api-version=2016-07-01
##[debug]Correlation ID from ARM api call response : b79bdf30-6fd1-4ff5-97af-955641ac01b3
##[debug]Deployment Failed with Error: Error: Resource 'request-to-pay-service' doesn't exist. Resource should exist before deployment.

This is the result of a az resource list command.

az resource list | grep 'request-'
    "id": "/subscriptions/.../resourceGroups/rs-core-production-australiaeast/providers/Microsoft.Web/serverFarms/request-to-pay-service-plan",
    "name": "request-to-pay-service-plan",
    "id": "/subscriptions/.../resourceGroups/rs-core-production-australiaeast/providers/Microsoft.Web/sites/request-to-pay-service",
    "name": "request-to-pay-service",

@v-ibshaik v-ibshaik added environment:under-investigation and removed environment:need-to-triage Issues need to be triage by environment-deployment team bug labels Nov 24, 2021
@v-saikumart
Copy link
Contributor

v-saikumart commented Nov 24, 2021

Hi @tomred-net

Could you please share the details like how you are creating the resources. Is it created via pipelines before deployment or already exists?

Thank you.

@tomred-net
Copy link
Author

tomred-net commented Nov 24, 2021

Hi @v-saikumart,

The App Service and App Service Plan resources are created using Terraform and have been provisioned for the last week. They can be deployed to through the portal and from terraform without issue.

The serviceConnection works for other deployments such as static apps.

The deployment step for the container is as follows:

variables:
  serviceConnection: azureServiceConnection # pipelines ARM serviceConnection
  ContainerNamespace: xxx.azurecr.io   # xxx is the url for the ACR
  ContainerRepository: xxx             # request-to-pay-service
  WebAppName: xxx                      # request-to-pay-service
  ContainerTag: latest                 # a valid tag
  
stages:
- stage: Deploy_App_Service
  - deployment: Deploy_App_Service
    strategy:
      runOnce: 
        deploy:
          steps:
          - checkout: self
            submodules: true
          - task: AzureRMWebAppDeployment@4
            displayName: Azure App Service Deploy
            inputs:
              appType: webAppContainer
              ConnectedServiceName: $(serviceConnection) 
              WebAppName: $(WebAppName)                  
              DockerNamespace: $(ContainerNamespace)     
              DockerRepository: $(ContainerRepository)   
              DockerImageTag: $(ContainerTag)            

@v-saikumart
Copy link
Contributor

@tomred-net

Can you share the details that you are experiencing the issue consistently or just immediately after creating app from terraform. And can you please run the mentioned GET API call from postman and confirm on same.

Thank you.

@tomred-net
Copy link
Author

tomred-net commented Nov 28, 2021

HI @v-saikumart,

I am experiencing this consistently.

The query from the request fails:

https://management.azure.com/subscriptions/.../resources?$filter=resourceType EQ 'Microsoft.Web%252FSites' AND name EQ 'request-to-pay-service'&api-version=2016-07-01 

{
    "value": []
}

When I fix the URL encoding it passes

https://management.azure.com/subscriptions/.../resources?$filter=resourceType EQ 'Microsoft.Web/Sites' AND name EQ 'request-to-pay-service'&api-version=2016-07-01

{
    "value": [
        {
            "id": "/.../request-to-pay-service",
            "name": "request-to-pay-service",
            "type": "Microsoft.Web/sites",
            "kind": "app,linux,container",
            "location": "australiaeast",
            "identity": {
                "principalId": "...",
                "tenantId": "...",
                "type": "SystemAssigned"
            },
            "tags": {}
        }
    ]
}

@v-saikumart
Copy link
Contributor

Hi @tomred-net
Could you please try
https://management.azure.com/subscriptions/.../resources?$filter=resourceType EQ 'Microsoft.Web%252FSites' AND name EQ 'request-to-pay-service'&api-version=2016-07-01 instead of
https://management.azure.com/subscriptions/.../resources?$filter=resourceType EQ 'Microsoft.Web/Sites' AND name EQ 'request-to-pay-service'&api-version=2016-07-01 and confirm on same.

Thank you.

@tomred-net
Copy link
Author

@v-saikumart as demonstrated in my previous reply I tried the first url (containing 'Microsoft.Web%252FSites' ) which is the same as the value submitted by the azure task and the result is an empty array.

{
    "value": []
}

If I replace the double url encoding of '/' then I get the successful results as shown in my previous answer.

To clarify / is encoded to %2f which appears to be re-encoded to %252f as original % is encoded as %25.
url_encode('/') = %2f
url_encode( url_encode('/') ) = %252f

@tomred-net
Copy link
Author

@v-saikumart @v-ibshaik is there anything else I can do to help you debug this issue?

@v-saikumart
Copy link
Contributor

v-saikumart commented Dec 15, 2021

@tomred-net Could you please share the below mentioned details, as we are try to reproduce the issue and it is working as expected.

i. Complete Pipeline logs.
ii. Complete YAML file.

Thank you.

@RSteeno
Copy link

RSteeno commented Jan 13, 2022

@tomred-net

Were you able to find a fix for this? I am experiencing a similar issue, but it is sporadic.

  1. Provision app service with Terraform
  2. Wait 5 minutes (previously I had a 60 second wait and it was working fine for weeks).
  3. Deploy web site via AzureWebApp@1 task

Up until yesterday this was working and now sometimes it works and other times it fails.

Error:

Got service connection details for Azure App Service:'app-xxxx-f48362-eaus'
##[error]Error: Resource 'app-xxxx-f48362-eaus' doesn't exist. Resource should exist before deployment.

@cswierczynski
Copy link

@tomred-net

Were you able to find a fix for this? I am experiencing a similar issue, but it is sporadic.

  1. Provision app service with Terraform
  2. Wait 5 minutes (previously I had a 60 second wait and it was working fine for weeks).
  3. Deploy web site via AzureWebApp@1 task

Up until yesterday this was working and now sometimes it works and other times it fails.

Error:

Got service connection details for Azure App Service:'app-xxxx-f48362-eaus'
##[error]Error: Resource 'app-xxxx-f48362-eaus' doesn't exist. Resource should exist before deployment.

I am also seeing the exact message. Was working up until today

@ikhoury-nlo
Copy link

@tomred-net

Were you able to find a fix for this? I am experiencing a similar issue, but it is sporadic.

  1. Provision app service with Terraform
  2. Wait 5 minutes (previously I had a 60 second wait and it was working fine for weeks).
  3. Deploy web site via AzureWebApp@1 task

Up until yesterday this was working and now sometimes it works and other times it fails.

Error:

Got service connection details for Azure App Service:'app-xxxx-f48362-eaus'
##[error]Error: Resource 'app-xxxx-f48362-eaus' doesn't exist. Resource should exist before deployment.

I've been trying to deploy my function app all day, exact same steps and error at the end. Using the AzureFunctionApp@1 task in a YAML pipeline. The app service plan perfectly exists in the azure portal, but not in devops. It also does not appear in the drop down when trying to create a classic release task. The service connection is owner in the target subscription, no reason for the function app "not to exist".

@ikhoury-nlo
Copy link

Just started working today! I hope it's a permanent fix...

@tomred-net
Copy link
Author

@tomred-net Could you please share the below mentioned details, as we are try to reproduce the issue and it is working as expected.

i. Complete Pipeline logs. ii. Complete YAML file.

Thank you.

Hi @v-saikumart,

I am sorry I did not receive a notification of you edits to your original reply, hence I did not notice the request for more information. I will run the deployment now and extract the logs. It is still failing for the same reason.

Dermot

@tomred-net
Copy link
Author

@v-saikumart

Please find attached both the log file and the azure-pipeline.yml

Dermot
azure-pipeline.yml.txt
failed.deployment.txt

@tomred-net
Copy link
Author

@RSteeno No fix so far. It is still happening for us.

@v-saikumart
Copy link
Contributor

@tomred-net Thank you for the response. We will investigate further and share the status accordingly.
Thank you.

@jschiessl
Copy link

Same problem for me and my team of 15 devs, this is heavily impacting us currently. The only difference to the behavior reported by @tomred-net is that is does not fail always, but very often. This is even more annoying.

@RSteeno
Copy link

RSteeno commented Jan 18, 2022

I have an case open with MSFT. The engineer referenced an ongoing Resource Manager issue dated Jan 13th which could be related.

https://status.azure.com/en-us/status/history/

@v-saikumart
Copy link
Contributor

v-saikumart commented Jan 19, 2022

@tomred-net Could please verify the SPN role and confirm the web app(request-to-pay-service) is present in that subscription(PAYGO Subscription).
Thank you.

@mdubdev
Copy link

mdubdev commented Jan 19, 2022

I too am dealing with this issue and have a support case open with MS. Please let me know if there is anything I can provide to assist in resolving this issue as it is causing a lot of issues for our devs. I also want to point out that this is happening with our function deployments as well.

@i3anaan
Copy link

i3anaan commented Nov 25, 2022

We ran into the same issue this week (EU West) with 2 newly created function apps.
Once it took about an hour to resolve itself, another time about a day.

We tried some things on our end to fix it, but nothing seems to have helped: It seems to have magically resolved itself

@lkfabu2022
Copy link

Wow, it's hitting a year now, with this issue still unresolved.

@simonp92
Copy link

simonp92 commented Dec 6, 2022

Just experienced this error on a new function app as well (test stage) - been trying the deployment for 2 hours with no luck. Has been working fine on dev stage

@metu
Copy link

metu commented Dec 14, 2022

Just started experiencing a similar issue in South Africa North. Was working fine in late November, now its giving an error about not being able to get the resource ID

@Conquintor
Copy link

We are still experiencing this issue for our Terraform/Devops pipelines. Workarounds are not 100% reliable, delays do work, but are increasing the duration of our pipelines by a lot. Resource creation and deployment via local machine with user credentials does not seem to have this problem.

@catinodeh
Copy link

It's 2023 and after 1 year of the first post, this hasn't yet been resolved. In our case, we are trying to move resources from one region to another. Functions don't have the "Move" option and therefore we need to delete it, re-create it and then go into DevOps to redeploy the code.

I understand the existing/old Pipeline (in Azure DevOps) will fail because the resource (ID) changed. Here's what I usually try:

1 - Refresh the existing Steps to force a Resource ID update (the dropdowns)
2 - Manually type in the name of the Resource in the Application dropdown (because, of course, it's not there)
3 - Create new pipelines to force a whole process
4 - Get the Service Principal and give Read permission under the Resource Group and the Resource itself
5 - Refresh the Service Connection inside the project

Nothing, I repeat, NOTHING guarantees that the next pipeline run will work. What works is just "wait for a random period and" try again.

I sincerely don't understand why this is still a thing.

@Vox1984
Copy link

Vox1984 commented Jan 26, 2023

Hi Guys, Just hit the issue today. Will it be fixed?

@borondy
Copy link

borondy commented Jan 27, 2023

Hi Guys! I've commented here long time ago. This issue basically roots in the inconsistency of the distributed storage in which Azure stores our resources metadata. When we create/update resources, they metadata initially gets stored in one (or at least, not in all the) location and as time goes it gets replicated to multiple metadata stores. Because of this delay, we can reach "ARM endpoints" which do not know about our resource creation/update yet. So it can happen that with your first call you are creating a resource which's metadata is stored in location A, and as a next step you try to deploy on it from Azure Pipelines (for example) but that deployment checks the existence of your resource in location B which simply does not contain your previous updates yet.
To overcome this challenge, we opened a support ticket in Azure Portal and it it turned out that we were eligible to migrate our Tenant's ARM (storage ?) to use CosmosDB. Since its replication latency was way more lower than the original solution's this solved our issue immediately.
I'm not sure I used the correct wording everywhere, but I'm sure you got the ideas :)

@nikkh
Copy link

nikkh commented Feb 8, 2023

I have just started getting this today - its really infuriating. My app did deploy once, but has failed before and since. I just created a brand new App Service and I am getting the same error on that (never seen it before on hundreds of others I have created over the years)

Got service connection details for Azure App Service:'RevelationMoonAdminNew'
##[debug][POST]https://login.windows.net/b02e6e0c-de2b-465f-ba6a-88d7c375af11/oauth2/token/
##[debug][GET]https://management.azure.com/subscriptions/a3ffcdfc-2958-4362-8ec6-259dbf71229f/resources?$filter=resourceType EQ 'Microsoft.Web%252FSites' AND name EQ 'RevelationMoonAdminNew'&api-version=2016-07-01
##[debug]Correlation ID from ARM api call response : 448d8eb9-f235-4cb6-8aea-875f4c883152
##[debug]Deployment Failed with Error: Error: Resource 'RevelationMoonAdminNew' doesn't exist. Resource should exist before deployment.
##[debug]task result: Failed
##[error]Error: Resource 'RevelationMoonAdminNew' doesn't exist. Resource should exist before deployment.
##[debug]Processed: ##vso[task.issue type=error;]Error: Resource 'RevelationMoonAdminNew' doesn't exist. Resource should exist before deployment.
##[debug]Processed: ##vso[task.complete result=Failed;]Error: Resource 'RevelationMoonAdminNew' doesn't exist. Resource should exist before deployment.
##[debug]Deployment failed

@adalfa
Copy link

adalfa commented Feb 8, 2023

@borondy same option the support gave us last year, I think Azure should make the feature GA...

@dribblor
Copy link

dribblor commented Feb 9, 2023

Same issue here. Between this issue and the intermittent 'service unavailable (code 503)' when it tries to mount the zip, function app deployments are painful right now.

@AlexEngblom
Copy link

To overcome this challenge, we opened a support ticket in Azure Portal and it it turned out that we were eligible to migrate our Tenant's ARM (storage ?) to use CosmosDB. Since its replication latency was way more lower than the original solution's this solved our issue immediately.

Sounds like this should be how it works behind the scene by default. At its current state, the Azure iac pipeline implementation is unstable and simply just broken. I wonder why Microsoft is sleeping on this?

@maartenvandiemen
Copy link

In the end it turns out the CLI is more reliable. So we used the solution previously mentioned.

I've managed to fix it with the workaround provided by Microsoft: we are now using the Azure CLI for deploying webapps and the Azure Functions tools for deploying Azure Functions.

Old app service deployment:

  - download: "current"
    displayName: "Download UI.Api"
    artifact: "UI.Api"
  - task: AzureRmWebAppDeployment@4
    displayName: "Deploy: UI.Api"
    retryCountOnTaskFailure: ${{ parameters.retryDeployCount }}
    inputs:
      ConnectionType: "AzureRM"
      azureSubscription: "$(azureResourceManagerConnection)"
      appType: "webApp"
      WebAppName: "app-api-${{ parameters.projectName }}-${{ parameters.environment }}"
      packageForLinux: "$(Pipeline.Workspace)/UI.Api/"
      enableCustomDeployment: true
      DeploymentType: "zipDeploy"
      enableXmlVariableSubstitution: true
      deployToSlotOrASE: ${{ parameters.useDeploymentSlots }}
      SlotName: "staging"
      resourceGroupName: "${{ parameters.resourceGroup }}"

New app service deployment:

  - download: "current"
    displayName: "Download UI.Api"
    artifact: "UI.Api"
  - task: FileTransform@1
    displayName: "Transform UI.Api"
    inputs:
      folderPath: "$(Pipeline.Workspace)/UI.Api/UI.Api.zip"
      fileType: "xml"
      targetFiles: "Web.config"
  - task: AzureCLI@2
    displayName: "Deploy UI.Api"
    retryCountOnTaskFailure: ${{ parameters.retryDeployCount }}
    inputs:
      azureSubscription: $(azureResourceManagerConnection)
      scriptType: ps
      scriptLocation: inlineScript
      inlineScript: |
        if ("${{ parameters.useDeploymentSlots }}" -eq "true") {
          az webapp config appsettings set `
          --resource-group "${{ parameters.projectName }}-${{ parameters.environment }}" `
          --name "app-api-${{ parameters.projectName }}-${{ parameters.environment }}" `
          --settings WEBSITE_RUN_FROM_PACKAGE="1" `
          --slot "staging"

          az webapp deployment source config-zip `
          --resource-group "${{ parameters.projectName }}-${{ parameters.environment }}" `
          --name "app-api-${{ parameters.projectName }}-${{ parameters.environment }}" `
          --src "$(Pipeline.Workspace)/UI.Api/UI.Api.zip" `
          --slot "staging"
        }
        else {
          az webapp config appsettings set `
          --resource-group "${{ parameters.projectName }}-${{ parameters.environment }}" `
          --name "app-api-${{ parameters.projectName }}-${{ parameters.environment }}" `
          --settings WEBSITE_RUN_FROM_PACKAGE="1"

          az webapp deployment source config-zip `
          --resource-group "${{ parameters.projectName }}-${{ parameters.environment }}" `
          --name "app-api-${{ parameters.projectName }}-${{ parameters.environment }}" `
          --src "$(Pipeline.Workspace)/UI.Api/UI.Api.zip"
        }

Old Azure Function deployment:

  - download: "current"
    displayName: "Download UI.Function"
    artifact: "UI.Function"
  - task: AzureFunctionApp@1
    displayName: "Deploy UI.Function"
    retryCountOnTaskFailure: ${{ parameters.retryDeployCount }}
    inputs:
      azureSubscription: "$(azureResourceManagerConnection)"
      appType: "functionApp"
      appName: "app-function-${{ parameters.projectName }}-${{ parameters.environment }}"
      package: "$(Pipeline.Workspace)/UI.Function"
      deploymentMethod: "zipDeploy"
      resourceGroupName: "${{ parameters.resourceGroup }}"
      appSettings: '-AzureDevopsToken "${{ parameters.azureDevopsToken }}" -EnvironmentName "${{ parameters.environment }}"'

New Azure Function deployment:

  - task: NodeTool@0
    displayName: "Use Node 14"
    inputs:
      versionSpec: 14.18.1
  - task: Npm@1
    displayName: "Install Azure Functions tools"
    inputs:
      command: "custom"
      customCommand: "install -g azure-functions-core-tools"
  - download: "current"
    displayName: "Download UI.Function"
    artifact: "UI.Function"
  - task: ExtractFiles@1
    displayName: "Extract UI.Function"
    inputs:
      archiveFilePatterns: "$(Pipeline.Workspace)/UI.Function/UI.Function.zip"
      destinationFolder: "$(Pipeline.Workspace)/Extracted/"
      cleanDestinationFolder: true
      overwriteExistingFiles: false
  - task: AzureCLI@2
    displayName: "Deploy UI.Function"
    retryCountOnTaskFailure: ${{ parameters.retryDeployCount }}
    inputs:
      workingDirectory: "$(Pipeline.Workspace)/Extracted/"
      azureSubscription: $(azureResourceManagerConnection)
      scriptType: pscore
      scriptLocation: inlineScript
      inlineScript: |
        az functionapp config appsettings set `
          --resource-group "${{ parameters.projectName }}-${{ parameters.environment }}" `
          --name "app-function-${{ parameters.projectName }}-${{ parameters.environment }}" `
          --settings AzureDevopsToken="${{ parameters.azureDevopsToken }}" EnvironmentName="${{ parameters.environment }}"

        func azure functionapp publish app-function-${{ parameters.projectName }}-${{ parameters.environment }} `
          --typescript

Some notes:

  • Release annotations in ApplicationInsight is not automatically added by the Azure CLI.
  • I recommend to still add and retryCountOnTaskFailure of minimal 2. It seems the deployment can be still flaky with newly created resources.

@v-nagarajku v-nagarajku removed their assignment Mar 27, 2023
@vienleidl
Copy link

I got the same issue when deloying to the new-created App Service. I had to wait for 2 days and try again, now the name of that App Service appears in the App Service name of Azure App Service deploy task (version: 4.*) in the Release pipeline.

@drakelundstromneudesic
Copy link

I am getting the same issue still with web app deploys. Going to try to implement the CLI workaround, but it is a bit disappointing that Azure still has this issue.

@greigs
Copy link

greigs commented May 18, 2023

I was getting this error with deploying to a new App Service with v4 ( I tried several times ). It worked with v3, after which I was immediately able to switch back to v4 and it worked.

@Vox1984
Copy link

Vox1984 commented May 18, 2023 via email

@SachinL9
Copy link

SachinL9 commented Oct 27, 2023

Yesterday I faced the below error when deploying function app via Azure Devops yaml pipeline:

##[error]Error: Resource 'fn-app1' doesn't exist. Resource should exist before deployment.

Interestingly, another pipeline with the same steps worked fine. The only difference was, different service principals (ADO service connections) were used in the two pipelines.

After comparing the service principals I found that mine had RBAC permissions on multiple subscriptions (including the function app subscription) where as the working one had permissions on only one subscription containing function app.

The Fix was simple - I created a new service principal with permissions to only the function app and related resources in same subscription. So "az account show" gives only one subscription in the output.

This is more of a workaround, but Hope it helps someone.

@iulian-popescu
Copy link

Any update? Lately it started becoming more and more unstable. I've also tried having the reset azure cache suggested, added 10 retries on the task and it is still failing.

@jdiazfernandez
Copy link

Any update?

I'm a teacher and was teaching Azure DevOps Pipelines to my students using this code and tutorial from mslearn and we are experimenting the same issue... It's very frustrating, as students don't know if they're configuring something wrong or there is any other problem.

It's the same issue described on nov 2021... I also tried adding delays between ARM taks and deploy task but it continues failing ramdonly.

The code students are using is here

For specifying the pipelines we are using the classic editor (as it's the first time they are configuring pipelines)

image

The deployment.json is here

https://github.com/ETSISI-EMS/mslearn-tailspin-spacegame-web/blob/main/azuredeploy.json

The error of deploy task is as follows:
Error: Resource 'webappw0140' doesn't exist. Resource should exist before deployment.
Unhandled: Cannot read properties of undefined (reading 'getApplicationURL')
TypeError: Cannot read properties of undefined (reading 'getApplicationURL')
at WindowsWebAppRunFromZipProvider. (D:\a_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.235.0\deploymentProvider\WindowsWebAppRunFromZipProvider.js:68:77)
at Generator.next ()
at fulfilled (D:\a_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.235.0\deploymentProvider\WindowsWebAppRunFromZipProvider.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

@jdiazfernandez
Copy link

also it would make sense that it would fail the first time the resources are created because it needs some delay but once the resources are created, why does the deploy fail? also why does it fail randomly?

@pdtit
Copy link

pdtit commented Feb 27, 2024

Starting seeing this issue of "resource not found" since this weekend, probably about the same timeframe as @jdiazfernandez . Pipeline exists for more than a year, all deployments successful, until Sunday... no real means to troubleshoot, as 'it just happened'.
We're deploying using Azure CLI scripts, not the WebApp deployment task.

@pdtit
Copy link

pdtit commented Feb 29, 2024

Didn't change anything in the pipeline definition, but it started working again today. for both WebApp deployments as well as Functions. Hopefully it is stabilized again...

@pdtit
Copy link

pdtit commented Mar 11, 2024

Unfortunately it isn't :(, switching my pipelines over from the default AzureWebApp and AzureFunction tasks to the CLI alternatives, as those seem to be more stable...

@georgii-sirotkin
Copy link

In my case the issue was caused by insufficient permissions. I had to assign Website Contributor role to the service principal.

@Sergey-Nosov-CloudFit
Copy link

It is very likely that permissions had nothing to do with it; but rather while you were adjusting permissions, Azure replication completed.

@Saibamen
Copy link

Nothing to do with permissions. I had this issue randomly in the past

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests