Share via

az lock delete question

ZM 211 Reputation points
2022-10-26T14:42:37.403+00:00

i received this error on my decom test when it was going through az lock delete

INFORMATION - Storage account for this customer exists, deleting...
ERROR: Unexpected --resource-group for lock delete_lock, expected uac-sui-int-ukwest-rg

However, my resource Group is actually "uac-hh-dev-ukwest-rg" Im not sure why its saying expected uac-sui-int-ukwest-rg but im going to edit my script to make sure it doesn’t happen again

Below is my code which I took from my script:

Write-Output "INFORMATION - Storage account for this customer exists, deleting..."  
az lock delete -n delete_lock -g $resourceGroup  

its pretty simply but I wanted to ask what shall I look at to make sure that error doesn’t come back again.
I was thinking maybe I could add an if statement or even an az lock delete show/list

Do you think that would work?

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments

1 answer

Sort by: Most helpful
  1. JimmySalian-2011 45,371 Reputation points Volunteer Moderator
    2022-10-26T15:41:51.55+00:00

    Hi,

    Yes it should work as it is simple az lock delete command and parsing the $RG however if you want advance script follow this page for detailed steps how-to-remove-all-empty-resource-groups-using-azure-cli

    Hope this helps.
    JS

    ==
    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.