diff --git a/.azure-devops/nightlybuild/mlz-bicep-azurecloud-pipelines.yml b/.azure-devops/nightlybuild/mlz-bicep-azurecloud-pipelines.yml index 96d40ddc6..a6399d25b 100644 --- a/.azure-devops/nightlybuild/mlz-bicep-azurecloud-pipelines.yml +++ b/.azure-devops/nightlybuild/mlz-bicep-azurecloud-pipelines.yml @@ -97,7 +97,13 @@ jobs: azureSubscription: $(ServiceConnectionName) scriptType: 'bash' scriptLocation: 'inlineScript' - inlineScript: 'az monitor diagnostic-settings subscription list --query "value[? contains(@.name, ''$1'')].name" -o table |grep ''mlz''| awk ''{system(" az monitor diagnostic-settings delete --resource ''"/subscriptions/$(subId)"'' --name "$1)}''' + inlineScript: | + az monitor diagnostic-settings subscription list \ + --query "value[].name" \ + --output tsv \ + | xargs -t -I % az monitor diagnostic-settings subscription delete \ + --yes \ + --name % - task: AzureCLI@2 displayName: "Clean up Resources" @@ -106,4 +112,11 @@ jobs: azureSubscription: $(ServiceConnectionName) scriptType: 'bash' scriptLocation: 'inlineScript' - inlineScript: 'az group list -o table | grep ''mlz'' | awk ''{system("az group delete -y --no-wait -g "$1)}''' + inlineScript: | + az group list \ + --query "[].name" \ + --output tsv \ + | xargs -t -I % az group delete \ + --yes \ + --no-wait \ + --name % diff --git a/.azure-devops/nightlybuild/mlz-bicep-azuregov-pipelines.yml b/.azure-devops/nightlybuild/mlz-bicep-azuregov-pipelines.yml index 9e7928349..f33d9ccfc 100644 --- a/.azure-devops/nightlybuild/mlz-bicep-azuregov-pipelines.yml +++ b/.azure-devops/nightlybuild/mlz-bicep-azuregov-pipelines.yml @@ -96,7 +96,13 @@ jobs: azureSubscription: $(GServiceConnectionName) scriptType: 'bash' scriptLocation: 'inlineScript' - inlineScript: 'az monitor diagnostic-settings subscription list --query "value[? contains(@.name, ''$1'')].name" -o table |grep ''mlz''| awk ''{system(" az monitor diagnostic-settings delete --resource ''"/subscriptions/$(GSubId)"'' --name "$1)}''' + inlineScript: | + az monitor diagnostic-settings subscription list \ + --query "value[].name" \ + --output tsv \ + | xargs -t -I % az monitor diagnostic-settings subscription delete \ + --yes \ + --name % - task: AzureCLI@2 displayName: "Clean up Resources" @@ -105,4 +111,11 @@ jobs: azureSubscription: $(GServiceConnectionName) scriptType: 'bash' scriptLocation: 'inlineScript' - inlineScript: 'az group list -o table | grep ''mlz'' | awk ''{system("az group delete -y --no-wait -g "$1)}''' + inlineScript: | + az group list \ + --query "[].name" \ + --output tsv \ + | xargs -t -I % az group delete \ + --yes \ + --no-wait \ + --name %