RSS

Azure Get-AzureSubscription: Same SubscriptionName And Blank SubscriptionID

25 Oct

I was going to set up a new azure environment for a new customer with a powershell script when I encountered the following error:

Get-AzureVNetConfig : Value cannot be null.
Parametername: subscriptionId
At line:1 char:1
+ Get-AzureVNetConfig
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-AzureVNetConfig], ArgumentNullException
+ FullyQualifiedErrorId : System.ArgumentNullException,Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.GetAzureVNetConfigCommand

It seems that I was too quick to start with the new environment. I had forgotten to download the latest publishsettings file which contains the new customer subscription.

What instead happened now was that it created a new subscription named “CUSTOMERNAME” with SubscriptionID blank.

I realized the mistake and downloaded the latest publishsettings file.

After the import I ran Get-AzureSubscription and then I had two subscriptions with the same name. The problem now was that every time I ran Select-AzureSubscription CUSTOMERNAME it would choose the wrong one with the empty SubscriptionId. Select-AzureSubscription only selects by name and not by subscription id.

Blank SubscriptionID

There are two solutions. Since the result from Get-AzureSubscription is stored in a local file and the azure commands use the subscription id we can manage the source file or the publishsettings file.

Solution 1 (the nice one) – Edit WindowsAzureProfile.xml
Got to C:\Users\UserName\AppData\Roaming\Windows Azure Powershell and open WindowsAzureProfile.xml
Look for:

<Name>CUSTOMERNAME</Name>
<RegisteredResourceProviders xmlns:d4p1=”http://schemas.microsoft.com/2003/10/Serialization/Arrays&#8221; />
<ResourceManagerEndpoint>https://management.azure.com/</ResourceManagerEndpoint&gt;
<SqlDatabaseDnsSuffix>.database.windows.net</SqlDatabaseDnsSuffix>
<SubscriptionId i:nil=”true”

Remove everything that is included in, and the section (be safe and take a copy first):

<AzureSubscriptionData>
….
</AzureSubscriptionData>

Save, restart your powershell and run Get-AzureSubscription again. And voila! The faulty subscription is gone.

Solution 2 (the ugly one) – Edit the publishsettings file

Open up the file and find the subscription name CUSTOMERNAME. Rename it to CUSTOMERNAME2, save and exit. Import the publishsettings file again.
If you now use Select-AzureSubscription CUSTOMER2 and run Get-AzureVNetConfig it will work.

 
Leave a comment

Posted by on 2014-10-25 in Okategoriserade

 

Tags: ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
The BC Docs Librarian

Tips and news for AL programmers

Stefan Maroń

Dynamics 365 Business Central

James Pearson

Thoughts about Dynamics 365 Business Central, Git, Azure DevOps, PowerShell, Automated Testing, Visual Studio Code...and maybe some other stuff

Roberto Stefanetti BLOG

MVP & MCT Microsoft Dynamics 365 Business Central, Powershell, Azure, SQL Server

JoeBrown

DevOps starts with culture!

Comments for DevOps ABCs Blog

Reflections from the ERP field

DevOps ABCs Blog

Reflections from the ERP field

Dynamics 365 Business Central for Partners

Reflections from the ERP field

Freddys blog

Learn something new... - then Teach someone!

Stefano Demiliani Technical Blog

Reflections from the ERP field

David Worthington's NAV Performance Blog

Micosoft Dynamics NAV Performance Testing & Optimization

Freddys Blog

Reflections from the ERP field

Marije Brummel Blog | Business Central, Azure and more...

Design Patterns, Performance, Clean Code

Vjeko.com

Ideas in the cloud

Goprowe AB

Reflections from the ERP field

ArcherPoint

Reflections from the ERP field

The NAV Viking´s Blog

- Sharing my experience in the Dynamics NAV world

Comments for

Reflections from the ERP field

Nav Can Be Fun

Its Really Fun to Work with Microsoft Dynamics Nav / D365 Business Central

%d bloggers like this: