azure-pipelines-tasks: AzureFileCopy storageAccount: not found. The selected service connection 'Service Principal' supports storage accounts of Azure Resource Manager type only.

When using AzureFileCopy, we have a transient error (fails half of the time, and happens much more often since 8-9 th of March

using YAML in a build pipeline

  - task: AzureFileCopy@4
    displayName: 'Copy linked template to store'
    name: AzureFileCopy
    inputs:
      SourcePath: 'xxxx'
      azureSubscription: 'Build subscription'
      Destination: AzureBlob
      storage: qpvstorage
      ContainerName: armtemplates
      BlobPrefix: '$(Build.BuildNumber)'
      sasTokenTimeOutInMinutes: 120

Full output of the task including system.debug info rawlog.txt

without system debug logging:

Starting: Copy linked template to store
==============================================================================
Task         : Azure file copy
Description  : Copy files to Azure Blob Storage or virtual machines
Version      : 4.200.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-file-copy
==============================================================================
Import-Module -Name C:\Modules\az_7.1.0\Az.Accounts\2.7.3\Az.Accounts.psd1 -Global
##[warning]Both Az and AzureRM modules were detected on this machine. Az and AzureRM modules cannot be imported in the same session or used in the same script or runbook. If you are running PowerShell in an environment you control you can use the 'Uninstall-AzureRm' cmdlet to remove all AzureRm modules from your machine. If you are running in Azure Automation, take care that none of your runbooks import both Az and AzureRM modules. More information can be found here: https://aka.ms/azps-migration-guide
Clear-AzContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue
Clear-AzContext -Scope Process
Connect-AzAccount -ServicePrincipal -Tenant 598e09b7-4cb7-4728-a5c0-6ae7395f428d -Credential System.Management.Automation.PSCredential -Environment AzureCloud @processScope
 Set-AzContext -SubscriptionId xxxx -TenantId xxxx
Import-Module -Name C:\Modules\az_7.1.0\Az.Resources\5.2.0\Az.Resources.psd1 -Global
Import-Module -Name C:\Modules\az_7.1.0\Az.Storage\4.1.1\Az.Storage.psd1 -Global
Import-Module -Name C:\Modules\az_7.1.0\Az.Compute\4.22.0\Az.Compute.psd1 -Global
Import-Module -Name C:\Modules\az_7.1.0\Az.Network\4.14.0\Az.Network.psd1 -Global
##[warning]A parameter cannot be found that matches parameter name 'and'.
##[error]Storage account: qpbuildenvstorage not found. The selected service connection 'Service Principal' supports storage accounts of Azure Resource Manager type only.
Finishing: Copy linked template to store

We were using version 3 of this task, this is currently still working well on other places, but in one specific pipeline this is failing for more than half of the requests.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 6
  • Comments: 15

Most upvoted comments

Just hit the issue, and it boils down to permissions.

This blog post shows which permissions are the absolute bare minimum, for this to work: https://www.mikaelsand.se/2022/03/upload-files-to-blob-with-minimal-access/

I can confirm the same behavior.

I can confirm we’ve started to see the same issue these past few days… The serviceConnection used IS of Azure RM kind, all the correct permissions exist and have not been touched, nothing changed on the storage… This is extremely annoying, does somebody figure out a workaround please ? Thank you