I recently had some issues trying to delete a resource in one of my resource groups in Azure, and when I decided to try and use powershell to do it I ran into more problems. So here is a short recap of what I did, in case somebody else runs into the same issues.
Background:
I have both an MPN account for my own company and an MSDN account from a company I work for, both are connected to the same Microsoft ID but are different subscriptions on different tenants.
So here's my issue. I wanted to delete some old resoures in the Azure portal so save some of my dev credits, but whenever I opened the resources in the portal they were just stuck loading forever.
After two days of this I got fed up and decided to fix it with powershell (which I probably should have been doing in the first place.
So what I did was fire up powershell, and run the following lines:
Import-Module Azure
Login-AzureRmAccount
Get-Subscription
Login-AzureRmAccount
Get-Subscription
And that produced the following error:
WARNING: Unable to
acquire token for tenant 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
So first I was met with one issue, then a new one when I tried the other, recommended path of fixing things.
Luckily for me this annoyed me, so I did some very quick google searching to find a workaround to get my workaround fixed, so I simply did this to log in instead:
Login-AzureRmAccount
-TenantId 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
Get-Subscription
Get-Subscription
And voilá! The subscription was available and everything was working fine.
And just to clearify how to delete the resources, just run the following commands
Get-AzureRmResource
Remove-AzureRmResource
Remove-AzureRmResource
Nothing big, but here's the entire solution in one blog post. Also, I'm a much happier man now with plenty of credits left on his Azure subscription.
No comments:
Post a Comment