'AzureFileCopy@3 equivalent on Linux agent
I'm using a window based agent in Azure Pipeline. One of the task is to copy over an artifact to an Azure Blob Storage.
- task: AzureFileCopy@3
displayName: 'Upload to Azure'
inputs:
sourcePath: '$(Pipeline.Workspace)/dist'
azureSubscription: 'My Subscription'
destination: 'AzureBlob'
storage: $(featureStorageName)
containerName: '$web'
Microsoft suggest to use az storage blob with task: AzureCLI@2
This task is written in PowerShell and thus works only when run on Windows agents. If your pipelines require Linux agents and need to copy files to an Azure Storage Account, consider running az storage blob commands in the Azure CLI task as an alternative.
Question
What would be the equivalent command that I can run on a Linux agent?
I think the skeleton would start like:
task: AzureCLI@2
inputs:
azureSubscription: 'My Subscription'
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: |
az ...
Solution 1:[1]
Please have a try with :
inlineScript: 'az storage blob upload --account-name MyStorageAccount --account-key 0000-0000 -f "path/to/file" -c MyContainer -n NewBlob'
You could refer to az storage azcopy blob upload for more information.
Solution 2:[2]
Should be something like this :
variables:
storageAccountName: 'test' #Your storage account name
containerName: 'test' #The container name which you want to copy files to
steps:
- task: AzureCLI@2
inputs:
azureSubscription: 'My Subscription'
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: 'az storage blob upload-batch --destination $(containerName) --account-name $(storageAccountName) --source $(Build.SourcesDirectory)'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Suki Ji-MSFT |
| Solution 2 | Andy Li-MSFT |
