microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.45k stars 2.6k forks source link

[BUG]: AzureWebAppContainerV1 fails with "cannot find module @azure/msal-node" #20164

Closed tifleadenisa closed 1 month ago

tifleadenisa commented 1 month ago

New issue checklist

Task name

AzureWebAppContainer

Task version

1.242.0

Issue Description

When trying to deploy an application using the Azure Web App on Container Deploy task we are receiving the following error: image

Expected: application deployed with the specified docker image Result: the above screenshot; we started getting the error this morning.

Environment type (Please select at least one enviroment where you face this issue)

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Ubuntu 20.04

Relevant log output

##[debug]Using node path: /externals/node10/bin/node
##[debug]loading inputs and endpoints
##[debug]loading INPUT_AZURESUBSCRIPTION
##[debug]loading INPUT_APPNAME
##[debug]loading INPUT_DEPLOYTOSLOTORASE
##[debug]loading INPUT_RESOURCEGROUPNAME
##[debug]loading INPUT_SLOTNAME
##[debug]loading INPUT_IMAGENAME
##[debug]loading INPUT_MULTICONTAINERCONFIGFILE
##[debug]loading INPUT_APPSETTINGS
##[debug]Agent.ProxyUrl=undefined
##[debug]task result: Failed
##[error]Unhandled: Cannot find module '@azure/msal-node'
##[debug]Processed: ##vso[task.issue type=error;source=TaskInternal;]Unhandled: Cannot find module '@azure/msal-node'
##[debug]Processed: ##vso[task.complete result=Failed;]Unhandled: Cannot find module '@azure/msal-node'
##[error]Error: Cannot find module '@azure/msal-node'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/home/localadmin/ado_agent/_work/_tasks/AzureWebAppContainer_15858991-8bac-4542-99e7-577fef9b5be6/1.242.0/node_modules/azure-pipelines-tasks-azure-arm-rest/azure-arm-common.js:22:14)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
##[debug]Processed: ##vso[task.issue type=error;source=TaskInternal;]Error: Cannot find module '@azure/msal-node'%0A    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)%0A    at Function.Module._load (internal/modules/cjs/loader.js:562:25)%0A    at Module.require (internal/modules/cjs/loader.js:692:17)%0A    at require (internal/modules/cjs/helpers.js:25:18)%0A    at Object.<anonymous> (/home/localadmin/ado_agent/_work/_tasks/AzureWebAppContainer_15858991-8bac-4542-99e7-577fef9b5be6/1.242.0/node_modules/azure-pipelines-tasks-azure-arm-rest/azure-arm-common.js:22:14)%0A    at Module._compile (internal/modules/cjs/loader.js:778:30)%0A    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)%0A    at Module.load (internal/modules/cjs/loader.js:653:32)%0A    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)%0A    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
##[section]Finishing: Azure Web App on Container Deploy: app

Full task logs with system.debug enabled

No response

Repro steps

steps:
- task: AzureWebAppContainer@1
  displayName: 'Azure Web App on Container Deploy: app'
  inputs:
    azureSubscription: ''
    appName: 'app'
    deployToSlotOrASE: true
    resourceGroupName: 'rg'
    slotName: staging
    containers: '$(container_registry)/$(image):$(tag)'
    appSettings: ''
tifleadenisa commented 1 month ago

@DenisNikulin5 @DmitriiBobreshev @starkmsu @kirill-ivlev @vmapetr

SteGriff commented 1 month ago

Same problem here, but with AzureRmWebAppDeployment, starting since version 4.242.0 was downloaded to our deployment agent at 14:46 GMT+1.

2024-07-17T13:57:09.9400232Z ##[section]Starting: Deploy Security API
2024-07-17T13:57:10.0142841Z ==============================================================================
2024-07-17T13:57:10.0143534Z Task         : Azure App Service deploy
2024-07-17T13:57:10.0144357Z Description  : Deploy to Azure App Service a web, mobile, or API app using Docker, Java, .NET, .NET Core, Node.js, PHP, Python, or Ruby
2024-07-17T13:57:10.0145102Z Version      : 4.242.0
2024-07-17T13:57:10.0145533Z Author       : Microsoft Corporation
2024-07-17T13:57:10.0146093Z Help         : https://aka.ms/azureappservicetroubleshooting
2024-07-17T13:57:10.0146773Z ==============================================================================
2024-07-17T13:57:11.6001327Z ##[error]Unhandled: Cannot find module '@azure/msal-node'
2024-07-17T13:57:11.6055711Z ##[error]Error: Cannot find module '@azure/msal-node'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (C:\azagent\A2\_work\_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.242.0\node_modules\azure-pipelines-tasks-azure-arm-rest\azure-arm-common.js:22:14)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
2024-07-17T13:57:11.6281594Z ##[section]Finishing: Deploy Security API

Affecting our capability to carry out live deployments...

I am going to workaround it by manually replacing the content of the 4.242.0 dir with the content of the last known good version. (Previously documented here: https://stegriff.co.uk/upblog/azure-devops-broke-iis-deployments-for-a-week)

johnterickson commented 1 month ago

We are actively investigating.

johnterickson commented 1 month ago

Nevermind - we are looking at something else that is in a related area.

For this one, folks should look at: https://developercommunity.visualstudio.com/t/ErrorUnhandled:-Cannot-find-module-az/10689864 https://developercommunity.visualstudio.com/t/Unhandled:-Cannot-find-module-azuremsa/10702133

taimoor-janjua commented 1 month ago

Same goes here, but with AzureFunctionApp version 1.242.1, it was working fine till yesterday with version 1.238.1

Starting: Azure Function App Deploy
==============================================================================
Task         : Azure Functions
Description  : Update a function app with .NET, Python, JavaScript, PowerShell, Java based web applications
Version      : 1.242.1
Author       : Microsoft Corporation
Help         : https://aka.ms/azurefunctiontroubleshooting
==============================================================================
##[error]Unhandled: Cannot find module '@azure/msal-node'
##[error]Error: Cannot find module '@azure/msal-node'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (C:\agent\_work\_tasks\AzureFunctionApp_501dd25d-1785-43e4-b4e5-a5c78ccc0573\1.242.1\node_modules\azure-pipelines-tasks-azure-arm-rest\azure-arm-common.js:22:14)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
suhalkiran9039 commented 1 month ago

We have two function app we are able to deploy in one and other is failing with same issue:-

Starting: Deploy Function App
==============================================================================
Task         : Azure Functions
Description  : Update a function app with .NET, Python, JavaScript, PowerShell, Java based web applications
Version      : 1.242.1
Author       : Microsoft Corporation
Help         : https://aka.ms/azurefunctiontroubleshooting
==============================================================================
##[error]Unhandled: Cannot find module '@azure/msal-node'
##[error]Error: Cannot find module '@azure/msal-node'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (C:\a\_tasks\AzureFunctionApp_501dd25d-1785-43e4-b4e5-a5c78ccc0573\1.242.1\node_modules\azure-pipelines-tasks-azure-arm-rest\azure-arm-common.js:22:14)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
Finishing: Deploy Function App
arananet commented 1 month ago

there's a workaround. Define the agent-specific version on your FunctionApp task call inside your YAML file.

My case:

Hope it helps.

pio-em commented 1 month ago

For me, updating the self-hosted agent to the latest version helped.

suhalkiran9039 commented 1 month ago

@arananet How to use a specific version of the task. The Yaml allows only AzureFunctionApp@2 or 1

arananet commented 1 month ago

@arananet How to use a specific version of the task. The Yaml allows only AzureFunctionApp@2 or 1

you can set as I set it there, specific version @2.238.1.

danorthogonal commented 1 month ago

I was getting this error using agent version 2.200.2 and updated to latest 3.241.0 and it resolved the issue for me.

v-schhabra commented 1 month ago

@tifleadenisa Could you try to upgrade the version of the self-hosted agent and check if it works for you?

mtsuggs commented 1 month ago

For me, updating the self-hosted agent to the latest version helped.

This also worked for me. Went from 2.193.1 to latest.

pawanadubey commented 1 month ago

I had the same issue, however after updating the agent it got resolved.