question

MADHUNAhmed-3798 avatar image
0 Votes"
MADHUNAhmed-3798 asked AhmedMadhun-8970 commented

Unable to run long CLI command from Azure CLI task in Azure DevOps

I am running the following command from Azure CLI in Azure portal, and it works.

az resource list -g RG_SE_Polisen_Dev --query "[?type=='Microsoft.Storage/storageAccounts'].name" --output tsv | xargs -n 1 -t -I "{}" az lock delete -n "DevTestLabs Lock" -g RG_SE_Polisen_Dev --resource "{}" --resource-type "Microsoft.Storage/storageAccounts"


Running the same command via Azure CLI task in Azure Devops pipelines for automation, getting the following error:
134560-2021-09-23-09h34-52.png



In Text:
E:\agent_1_work\r30\a>az resource list -g RG_SE_Polisen_Dev --query "[?type=='Microsoft.KeyVault/vaults'].name" --output tsv | xargs -n 1 -t -I '{}' az lock delete -n "DevTestLabs Lock" -g RG_SE_Polisen_Dev --resource '{}' --resource-type "Microsoft.KeyVault/vaults"
2021-09-23T07:31:36.4258125Z az lock delete -n DevTestLabs Lock -g RG_SE_Polisen_Dev --resource SEDEVDTL9342
2021-09-23T07:31:36.4258390Z --resource-type Microsoft.KeyVault/vaults
2021-09-23T07:31:37.8440554Z ERROR: Operation returned an invalid status 'Bad Request'
2021-09-23T07:31:37.9668128Z ##[error]Script failed with error: Error: E:\agent_1_work_temp\azureclitaskscript1632382287742.bat failed with return code: 123

not-supported
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I managed to apply a work around by doing it in the following code:

 for /f "delims=" %%i in ('az resource list -g RG_SE_Polisen_Dev --query "[?type=='Microsoft.KeyVault/vaults'].name" --output tsv') do set output=%%i
    
 az lock delete --ids "/subscriptions/{SubID}/resourcegroups/{Rg_name}/providers/Microsoft.KeyVault/vaults/%output%/providers/Microsoft.Authorization/locks/DevTestLabs Lock"


0 Votes 0 ·

1 Answer

DSPatrick avatar image
0 Votes"
DSPatrick answered

Devops / TFS is not currently supported here on Q&A. The product group for Azure DevOps / TFS actively monitors questions over at
https://developercommunity.visualstudio.com/report?space=21&entry=problem
https://developercommunity.visualstudio.com/report?space=22&entry=problem

--please don't forget to upvote and Accept as answer if the reply is helpful--


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.