az lock delete question

ZM 206 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 Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,182 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JimmySalian-2011 39,426 Reputation points
    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.