Azure App Service Deploy pipeline task error: Resource doesn't exist/UnhandledPromiseRejectionWarning when resource exists

MDubDev 41 Reputation points
2022-01-10T20:59:02.597+00:00

Getting the following error while running an Azure DevOps pipeline that uses the Azure App Service Deploy task when the resource clearly exists. This is happening in an existing pipeline that historically works.

Got service connection details for Azure App Service:'blah'
##[error]Error: Resource 'blah' doesn't exist. Resource should exist before deployment.
(node:2432) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'getApplicationURL' of undefined
    at WindowsWebAppWebDeployProvider.<anonymous> (D:\a\_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.195.4\deploymentProvider\AzureRmWebAppDeploymentProvider.js:54:73)
    at Generator.next (<anonymous>)
    at D:\a\_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.195.4\deploymentProvider\AzureRmWebAppDeploymentProvider.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (D:\a\_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.195.4\deploymentProvider\AzureRmWebAppDeploymentProvider.js:4:12)
    at WindowsWebAppWebDeployProvider.UpdateDeploymentStatus (D:\a\_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.195.4\deploymentProvider\AzureRmWebAppDeploymentProvider.js:48:16)
    at D:\a\_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.195.4\azurermwebappdeployment.js:38:42
    at Generator.throw (<anonymous>)
    at rejected (D:\a\_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.195.4\azurermwebappdeployment.js:6:65)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:2432) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:2432) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,933 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ajkuma 28,036 Reputation points Microsoft Employee Moderator
    2022-07-19T19:23:14.073+00:00

    Typically, error thrown indicates user issued create database request whereas the logical server is not in ready state to get the database created.

    We would suggest user to wait for logical server creation and associated update of logical server to complete before creating logical DB.
    Or create logical DB immediately after logical server creation complete, then update logical server related properties in ARM template.

    Hence, as an alternative is to introduce a Wait operation into the ARM template for delaying the script execution until the background task has finished.
    The Wait can be achieved by using the deploymentScripts feature; deploymentScripts allows you to inject script commands into the ARM deployment and, for example, execute a PowerShell sleep command.

    The key is to set the dependencies of the steps correctly. You need to make the wait/sleep operation depending on the preceding deployment step, then have the next deployment step depending on the wait/sleep operation. You usually declare dependencies by referring to the resourceId of the object that was deployed on the preceding step, but you can also use the name of the preceding step.

    You may check out the suggestions in these doc, as a reference:
    Microsoft.Resources deploymentScripts and Work with outputs from PowerShell script

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.