Reputation: 424
I'm trying to use the --if-unmodified-since
flag on the delete-batch
command to delete files, but Azure throws an error on my inline script.
I'm doing this in Azure DevOps on an Ubuntu VM using an azure-pipelines.yml file.
This command:
- task: AzureCLI@2
displayName: Delete old files
inputs:
azureSubscription: 'Main subscription (xxx-xxx-xxx)'
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
az storage blob delete-batch -s $web --account-name mystorage --if-unmodified-since `date -d "1 days ago" '+%Y-%m-%dT%H:%MZ'`
Returns an Incomplete string token
error, pointing at the end of the inline script.
Upvotes: 2
Views: 2123
Reputation: 600
Backtick (`) is used for escaping characters in powershell, so I think it is easier to use $( command ) to execute nested commands [date -d "1 days ago" '+%Y-%m-%dT%H:%MZ' is a linux command]
Here the task, which worked for me
- task: AzureCLI@2
inputs:
azureSubscription: 'Visual Studio Professional Subscription(xxxxxx)'
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: 'az storage blob delete-batch -s images --account-name mystorage --if-unmodified-since $(date -d `"5 days ago`" ''+%Y-%m-%dT%H:%MZ'')'
Upvotes: 3