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 )

Google photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s

 
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

Mark Brummel Blog | Microsoft Dynamics NAV

Master Classes Design Patterns and more...

Vjeko.com

ideas in the cloud

Goprowe AB

Reflections from the ERP field

ArcherPoint Developer Blog

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

Navision-Girl.Com

Reflections from the ERP field

Kine's Info

Reflections from the ERP field

blog.wibeck.org/

Just another WordPress.com site

%d bloggers like this: