microsoft / azure-pipelines-tasks

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

[BUG]: AzureFileCopy@6 is breaking on pipeline with error 'The term 'New-AzStorageContext' is not recognized. #20150

Closed abhinab22mohanty closed 2 weeks ago

abhinab22mohanty commented 1 month ago

New issue checklist

Task name

AzureFileCopy

Task version

6.242.6

Issue Description

We recently upgraded the Azure DevOps (ADO) service connection from using an Azure Resource Manager service principal (automatic) to Azure Resource Manager using Workload Identity federation with OpenID Connect (automatic). There were couple successful runs but recently started getting error "The term 'New-AzStorageContext' is not recognized as the name of a cmdlet"

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

Azure DevOps Server type

Azure DevOps Server (Please specify exact version in the textbox below)

Azure DevOps Server Version (if applicable)

No response

Operation system

Windows 11

Relevant log output

2024-07-16T00:26:49.0813915Z ##[section]Starting: AzureFileCopy@6 (windows_build_container)
2024-07-16T00:26:49.0819407Z ==============================================================================
2024-07-16T00:26:49.0819519Z Task         : Azure file copy
2024-07-16T00:26:49.0819566Z Description  : Copy files to Azure Blob Storage or virtual machines
2024-07-16T00:26:49.0819634Z Version      : 6.242.6
2024-07-16T00:26:49.0819685Z Author       : Microsoft Corporation
2024-07-16T00:26:49.0819739Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-file-copy
2024-07-16T00:26:49.0819820Z ==============================================================================
2024-07-16T00:26:52.1404395Z ##[command]Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\3.0.2\Az.Accounts.psd1 -Global
2024-07-16T00:26:53.4767258Z ##[command]Update-AzConfig -DisplayBreakingChangeWarning False -AppliesTo Az
2024-07-16T00:26:53.6520511Z 
2024-07-16T00:26:53.7094087Z ##[command]Enable-AzureRmAlias -Scope Process
2024-07-16T00:26:55.7931368Z ##[command]Clear-AzContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue
2024-07-16T00:26:55.9181172Z ##[command]Clear-AzContext -Scope Process
2024-07-16T00:26:55.9505739Z ##[command]Connect-AzAccount 
2024-07-16T00:26:55.9506025Z Name                           Value                                           
2024-07-16T00:26:55.9506231Z ----                           -----                                           
2024-07-16T00:26:55.9506378Z Tenant                         975f013f-7f24-47e8-a7d3-abc4752bf346            
2024-07-16T00:26:55.9506514Z Scope                          Process                                         
2024-07-16T00:26:55.9506721Z Environment                    AzureCloud                                      
2024-07-16T00:26:55.9507153Z ApplicationId                  ***            
2024-07-16T00:26:55.9507372Z ServicePrincipal               True                                            
2024-07-16T00:26:55.9507449Z 
2024-07-16T00:26:55.9507557Z 
2024-07-16T00:26:55.9507594Z 
2024-07-16T00:26:56.0177372Z ##[warning]The feature related to parameter name 'FederatedToken' is under preview.
2024-07-16T00:26:57.3002063Z Key                          Value Applies To Scope       Help Message         
2024-07-16T00:26:57.3006293Z ---                          ----- ---------- -----       ------------         
2024-07-16T00:26:57.3015610Z DisplayBreakingChangeWarning False Az         CurrentUser Controls if warnin...
2024-07-16T00:26:57.3015718Z 
2024-07-16T00:26:57.3020261Z Environments : {[AzureChinaCloud, AzureChinaCloud], [AzureCloud, AzureCloud], 
2024-07-16T00:26:57.3020651Z                [AzureUSGovernment, AzureUSGovernment]}
2024-07-16T00:26:57.3021981Z Context      : Microsoft.Azure.Commands.Profile.Models.Core.PSAzureContext
2024-07-16T00:26:57.3022188Z 
2024-07-16T00:26:57.3439634Z ##[command]Set-AzContext 
2024-07-16T00:26:57.3439948Z Name                           Value                                           
2024-07-16T00:26:57.3440108Z ----                           -----                                           
2024-07-16T00:26:57.3440257Z SubscriptionId                 bc970a64-0a20-44e7-a673-a1b9f20b0ca0            
2024-07-16T00:26:57.3440335Z 
2024-07-16T00:26:57.3440378Z 
2024-07-16T00:26:57.3440421Z 
2024-07-16T00:26:57.5202374Z 
2024-07-16T00:26:57.5207244Z Name               : SxGICon_OneChat_RD (bc970a64-0a20-44e7-a673-a1b9f20b0ca0) 
2024-07-16T00:26:57.5207554Z                      - 975f013f-7f24-47e8-a7d3-abc4752bf346 - 
2024-07-16T00:26:57.5208079Z                      ***
2024-07-16T00:26:57.5209029Z Subscription       : bc970a64-0a20-44e7-a673-a1b9f20b0ca0
2024-07-16T00:26:57.5209983Z Account            : ***
2024-07-16T00:26:57.5211342Z Environment        : AzureCloud
2024-07-16T00:26:57.5212363Z Tenant             : 975f013f-7f24-47e8-a7d3-abc4752bf346
2024-07-16T00:26:57.5212766Z TokenCache         : 
2024-07-16T00:26:57.5213464Z VersionProfile     : 
2024-07-16T00:26:57.5214543Z ExtendedProperties : {}
2024-07-16T00:26:57.5214840Z 
2024-07-16T00:26:58.0652238Z ##[error]The term 'New-AzStorageContext' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
2024-07-16T00:26:58.1028890Z ##[section]Finishing: AzureFileCopy@6 (windows_build_container)

Full task logs with system.debug enabled

 [REPLACE THIS WITH YOUR INFORMATION] 

Repro steps

Below is the task we are running

        - task: AzureFileCopy@6
          inputs:
            SourcePath: '$(OUTPUTROOT)/build/dist/main.bundle*.js'
            azureSubscription: 'SxGICon_OCC_INT_MI'
            Destination: 'AzureBlob'
            storage: 'occstoragecommondev'
            ContainerName: 'chat-client-bundle-cdn-dev'
v-schhabra commented 1 month ago

Hi @abhinab22mohanty Thanks for reporting the issue. Could you please share the complete pipeline logs by adding variable system.debug to "true"?

abhinab22mohanty commented 1 month ago

ErrorLogs.txt Sure uploaded the Error log form the pipeline run : https://dev.azure.com/dynamicscrm/OneCRM/_build/results?buildId=15035728&view=logs&s=d4a9a205-d52e-57fb-7b17-15a9d984af62

ghost commented 1 month ago

Hi, is there any update on this? we’ve been facing some problems with many tasks of this repository over the past 5-6 weeks. There has been a noticeable and concerning increase in tasks breaking (recently azure power shell, web app, file copy etc), which is heavily impacting our org operations. I’m sure we’re not the only team dealing with these frustrations.

The lack of adequate testing, proactive monitoring, and early resolution of these issues is glaring. It’s become incredibly frustrating for myself and many of my team members. We used to report issues and raise PRs in this repo, and they were acknowledged and resolved within a few hours. Lately, however, the proactive responses from the support team have disappeared.

It’s not good that for each issue, we now have to spend time reaching out to the dev community, Stack Overflow, and Microsoft support. This is consuming valuable time and severely impacting our operations. The long waits for resolution are causing significant disruptions.

I’ve noticed contributors like @v-schhabra @v-snalawade @manolerazvan @garun-kumar and few more have approved many PRs related to these tasks. the monitoring of this repo needs to be stepped up significantly, with proactive measures taken to reduce future outages. It’s difficult to continue to operate with such instability. Please do check action to rectify these issues and restore the level of support we previously experienced.

v-snalawade commented 1 month ago

Hi, is there any update on this? we’ve been facing some problems with many tasks of this repository over the past 5-6 weeks. There has been a noticeable and concerning increase in tasks breaking (recently azure power shell, web app, file copy etc), which is heavily impacting our org operations. I’m sure we’re not the only team dealing with these frustrations.

The lack of adequate testing, proactive monitoring, and early resolution of these issues is glaring. It’s become incredibly frustrating for myself and many of my team members. We used to report issues and raise PRs in this repo, and they were acknowledged and resolved within a few hours. Lately, however, the proactive responses from the support team have disappeared.

It’s not good that for each issue, we now have to spend time reaching out to the dev community, Stack Overflow, and Microsoft support. This is consuming valuable time and severely impacting our operations. The long waits for resolution are causing significant disruptions.

I’ve noticed contributors like @v-schhabra @v-snalawade @manolerazvan @garun-kumar and few more have approved many PRs related to these tasks. the monitoring of this repo needs to be stepped up significantly, with proactive measures taken to reduce future outages. It’s difficult to continue to operate with such instability. Please do check action to rectify these issues and restore the level of support we previously experienced.

can you share the details of task and issue you are facing. we will check on it

lohitakshgupta commented 1 month ago

Facing a similar issue in our pipeline as well:

##[error]The term 'New-AzStorageContext' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
##[debug]Processed: ##vso[task.logissue type=error;source=TaskInternal;correlationId=df587367-2f6e-4ad8-a965-cdfb4b14fc7e]The term 'New-AzStorageContext' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
##[debug]Processed: ##vso[task.complete result=Failed]

Task has been setup this way:

        - task: AzureFileCopy@6
          displayName: 'Copy site content to Azure Storage'
          condition: and(succeeded(), eq(variables['AccessibilityTestingOnly'], 'false'))
          inputs:
            SourcePath: packages/doc-site/build/*
            ConnectedServiceNameARM: ***************
            Destination: AzureBlob
            StorageAccountRM: ******************
            ContainerName: $web
            BlobPrefix: azure-devops

Based on this error message: Could not find the module Az.Accounts with given version. If the module was recently installed, retry after restarting the Azure Pipelines task agent., I also tried installing Az.Accounts module separately:

        - task: PowerShell@2
          displayName: 'Install Az Module'
          inputs:
            targetType: 'inline'
            script: 'Install-Module -Name Az.Accounts -Scope AllUsers -AllowClobber -Force'

But then ended up getting the above error

Saransh-K commented 1 month ago

Hello we are facing a similar issue with our pipeline as well.

For this pipeline: https://msazure.visualstudio.com/One/_build/results?buildId=98883452&view=logs&j=15dfcb1a-0989-5cf6-3160-3e181e44de87&t=7f38a826-dcdc-5dce-32e2-bd5be705b052

We are getting this error:

##[error]Could not find the module Az.Accounts with given version. If the module was recently installed, retry after restarting the Azure Pipelines task agent.

And this is the pipeline task:

- task: AzureFileCopy@6
      inputs:
        SourcePath: '$(Build.SourcesDirectory)/crc-portal' # Path to the directory you want to upload
        azureSubscription: '$(serviceConnection)' # Your service connection name
        Destination: 'AzureBlob'
        storage: '$(storageAccount)' # Your storage account name
        ContainerName: '$(containerName)' # The name of your blob storage container
        BlobPrefix: 'filedump' # Prefix to maintain the directory structure in blob
        sasTokenTimeOutInMinutes: 240

Here is a more detailed error with system.debug set to true:

##[debug]Importing function 'Remove-EndpointSecrets'.
##[debug]Importing function 'Update-PSModulePathForHostedAgentWithLatestModule'.
##[debug]ENDPOINT_URL_a1533ba0-334b-46a7-af00-bdb271607052: 'https://management.azure.com/'
##[debug]ENDPOINT_AUTH_a1533ba0-334b-46a7-af00-bdb271607052: '********'
##[debug]ENDPOINT_DATA_a1533ba0-334b-46a7-af00-bdb271607052: '{"environment":"AzureCloud","scopeLevel":"Subscription","subscriptionId":"88e54977-85c2-43c8-908a-34caf6c7b8a4","subscriptionName":"Azure-CRC-Bare-Metal","resourceGroupName":"","mlWorkspaceName":"","mlWorkspaceLocation":"","managementGroupId":"","managementGroupName":"","oboAuthorization":"","creationMode":"Automatic","azureSpnRoleAssignmentId":"51dc1884-6fb9-43bf-b75c-934cdaa5a523","azureSpnPermissions":"[{\"roleAssignmentId\":\"51dc1884-6fb9-43bf-b75c-934cdaa5a523\",\"resourceProvider\":\"Microsoft.RoleAssignment\",\"provisioned\":true}]","spnObjectId":"d6d8d64c-76b4-4e19-bec0-e44dbf25d0de","appObjectId":"23e13e3a-f6d8-49f6-9cc5-a7ea127d6003","resourceId":"","revertSchemeDeadline":"revertSchemeDeadlineExpired","environmentUrl":"[https://management.azure.com/","galleryUrl":"https://gallery.azure.com/","serviceManagementUrl":"https://management.core.windows.net/","resourceManagerUrl":"https://management.azure.com/","activeDirectoryAuthority":"https://login.microsoftonline.com/","environmentAuthorityUrl":"https://login.windows.net/","microsoftGraphUrl":"https://graph.microsoft.com/","managementPortalUrl":"https://manage.windowsazure.com/","armManagementPortalUrl":"https://portal.azure.com/","activeDirectoryServiceEndpointResourceId":"https://management.core.windows.net/","sqlDatabaseDnsSuffix":".database.windows.net","AzureKeyVaultDnsSuffix":"vault.azure.net","AzureKeyVaultServiceEndpointResourceId":"https://vault.azure.net","StorageEndpointSuffix":"core.windows.net","EnableAdfsAuthentication":"false"}'](https://management.azure.com/%22,%22galleryUrl%22:%22https://gallery.azure.com/%22,%22serviceManagementUrl%22:%22https://management.core.windows.net/%22,%22resourceManagerUrl%22:%22https://management.azure.com/%22,%22activeDirectoryAuthority%22:%22https://login.microsoftonline.com/%22,%22environmentAuthorityUrl%22:%22https://login.windows.net/%22,%22microsoftGraphUrl%22:%22https://graph.microsoft.com/%22,%22managementPortalUrl%22:%22https://manage.windowsazure.com/%22,%22armManagementPortalUrl%22:%22https://portal.azure.com/%22,%22activeDirectoryServiceEndpointResourceId%22:%22https://management.core.windows.net/%22,%22sqlDatabaseDnsSuffix%22:%22.database.windows.net%22,%22AzureKeyVaultDnsSuffix%22:%22vault.azure.net%22,%22AzureKeyVaultServiceEndpointResourceId%22:%22https://vault.azure.net%22,%22StorageEndpointSuffix%22:%22core.windows.net%22,%22EnableAdfsAuthentication%22:%22false%22%7D')
##[debug]C:\Modules\azurerm_2.1.0 is not present in C:\Users\ContainerAdministrator\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\Storage;C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell;C:\Program Files\Azure Cosmos DB Emulator\PSModules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\Storage;C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell;C:\Program Files\Azure Cosmos DB Emulator\PSModules;
##[debug]C:\\Modules\azurerm_2.1.0 is not present in C:\Users\ContainerAdministrator\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\Storage;C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell;C:\Program Files\Azure Cosmos DB Emulator\PSModules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\Storage;C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell;C:\Program Files\Azure Cosmos DB Emulator\PSModules;
##[debug]C:\Modules\azure_2.1.0 is not present in C:\Users\ContainerAdministrator\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\Storage;C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell;C:\Program Files\Azure Cosmos DB Emulator\PSModules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\Storage;C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell;C:\Program Files\Azure Cosmos DB Emulator\PSModules;
##[debug]C:\\Modules\azure_2.1.0 is not present in C:\Users\ContainerAdministrator\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\Storage;C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell;C:\Program Files\Azure Cosmos DB Emulator\PSModules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\Storage;C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell;C:\Program Files\Azure Cosmos DB Emulator\PSModules;
##[debug]ENDPOINT_URL_SystemVssConnection: 'https://msazure.visualstudio.com/'
##[debug]ENDPOINT_AUTH_SystemVssConnection: '********'
##[debug]ENDPOINT_DATA_SystemVssConnection (empty)
##[debug]No module found with name: Az.Accounts
##[debug]Caught exception from task script.
##[debug]Error record:
##[debug]Could not find the module Az.Accounts with given version. If the module was recently installed, retry after restarting the Azure Pipelines task agent.
##[debug]At C:\__w\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\6.242.10\AzureFileCopy.ps1:70 char:5
##[debug]+     throw ("Could not find the module Az.Accounts with given version. ...
##[debug]+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
##[debug]    + CategoryInfo          : OperationStopped: (Could not find ...nes task ag    ent.:String) [], RuntimeException
##[debug]    + FullyQualifiedErrorId : Could not find the module Az.Accounts with given     version. If the module was recently installed, retry after restarting the     Azure Pipelines task agent.
##[debug] 
##[debug]Script stack trace:
##[debug]at <ScriptBlock>, C:\__w\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\6.242.10\AzureFileCopy.ps1: line 70
##[debug]at <ScriptBlock>, <No file>: line 1
##[debug]at <ScriptBlock>, <No file>: line 22
##[debug]at <ScriptBlock>, <No file>: line 18
##[debug]at <ScriptBlock>, <No file>: line 1
##[debug]Exception:
##[debug]System.Management.Automation.RuntimeException: Could not find the module Az.Accounts with given version. If the module was recently installed, retry after restarting the Azure Pipelines task agent.
##[error]Could not find the module Az.Accounts with given version. If the module was recently installed, retry after restarting the Azure Pipelines task agent.
##[debug]Processed: ##vso[task.logissue type=error;source=TaskInternal;correlationId=f42d0b5c-f415-4c2e-814b-ae06391dec82]Could not find the module Az.Accounts with given version. If the module was recently installed, retry after restarting the Azure Pipelines task agent.
##[debug]Processed: ##vso[task.complete result=Failed]
##[debug]Handler exit code: 0
v-schhabra commented 1 month ago

Hi @Saransh-K Could you please install Az module in your agent machine and let us know if still you are encountering the same issue?

Saransh-K commented 1 month ago

Can you help me with this?

I tried adding this task to my YAML:

- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |
      Install-Module -Name Az -Force
      Install-Module -Name Az.Accounts -Force

But I got this error:

Install-NuGetClientBinaries : Exception calling "ShouldContinue" with "2" 
argument(s): "Windows PowerShell is in NonInteractive mode. Read and Prompt 
functionality is not available."
At C:\Program 
Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1762 char:9
+         Install-NuGetClientBinaries -CallerPSCmdlet $PSCmdlet -Proxy  ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-NuGetClientBinaries], 
    MethodInvocationException
    + FullyQualifiedErrorId : PSInvalidOperationException,Install-NuGetClientB 
   inaries

I also tried adding -AllowClobber -Scope CurrentUser to the Install-Module but that didn't seem to fix it.

v-schhabra commented 1 month ago

Hi @Saransh-K As discussed offline please install Nuget packages on the agent machine if you are using 1ES agents?

Saransh-K commented 1 month ago

My pipeline is running on the default 1ES OneBranch pool. With this container image: onebranch.azurecr.io/windows/ltsc2019/vse2022:latest

As per offline discussion I added this powershell task before the AzureFileCopy and it fixed it.

- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |
      Write-Output (Get-PackageProvider -ListAvailable)
      Install-PackageProvider Nuget -ForceBootstrap -Force
      Install-Module -Name Az -RequiredVersion 10.0.0 -Force -AllowClobber -Scope CurrentUser
v-snalawade commented 4 weeks ago

ErrorLogs.txt Sure uploaded the Error log form the pipeline run : https://dev.azure.com/dynamicscrm/OneCRM/_build/results?buildId=15035728&view=logs&s=d4a9a205-d52e-57fb-7b17-15a9d984af62

From the logs it seems modules were not imported New-AzStorageContext is part of Az.Storage module.

Can you please check if modules are installed correctly

you can run below command in powershell on machine where agent is hosted. Get-Module -Name Az.* -ListAvailable

See if Az.storage is available if not then please install the modules and try to run the pipeline.

v-snalawade commented 3 weeks ago

ErrorLogs.txt Sure uploaded the Error log form the pipeline run : https://dev.azure.com/dynamicscrm/OneCRM/_build/results?buildId=15035728&view=logs&s=d4a9a205-d52e-57fb-7b17-15a9d984af62

did you tried installing Az.Storage module

v-snalawade commented 2 weeks ago

From the logs it seems modules were not imported New-AzStorageContext is part of Az.Storage module.

Can you please check if modules are installed correctly

you can run below command in powershell on machine where agent is hosted. Get-Module -Name Az.* -ListAvailable

See if Az.storage is available if not then please install the modules and try to run the pipeline.