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

Solution 1:

The last couple of days I have the same problem. No changes in deployments/configs anywhere. Deployment works unstable, it means that after 'rerun failed job' it can deploy successfully, but after rerun, it can again fail. Meantime, AppService is presented on the Portal GUI and can be checked through CLI, and I am able to use it (browse use external URI), so it's available.

Error:

Got service connection details for Azure App Service:'<application-name>'
##[error]Error: Resource '<application-name>' doesn't exist. Resource should exist before deployment.
(node:5328) 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:5328) 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:5328) [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.
##[section]Finishing: Deploy files to AppService