1
votes

After updating my Powershell with the November 2014 updates, the Import-PublishedSettingsFile commandlet is creating a subscription file in JSON format instead of XML.

How do I get a file in XML format? There are not output format options.

BACKGROUND The change appears to be causing an invalid account error when I attempt to run commandlets that rely on the current subscription. One example is Get-AzureService which returns this error:

Get-AzureService : Account with name '68BC909D63F2A51F987005620552FB1D643E03DE' does not exist. Parameter name: accountName At C:\UtilityScripts\Modules\AzureVdcConfigFileGenerate\AzureVdcConfigFileGenerate.psm1:189 char:42 + [object] $script:aSourceVdcService = Get-AzureService -ServiceName $sSourceV ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-AzureService], ArgumentException + FullyQualifiedErrorId : System.ArgumentException,Microsoft.WindowsAzure.Commands.ServiceManagement.HostedServices.GetAzureServiceCommand

I set up the subscriptions as follows:

Set-AzureSubscription -SubscriptionName  $sSourceSubscriptionName   -SubscriptionDataFile $sSourceSubscriptionFileName -CurrentStorageAccountName $sSourceStorageAccountName
Select-AzureSubscription -SubscriptionDataFile $sSourceSubscriptionFileName -NoDefault 
Select-AzureSubscription -SubscriptionDataFile $sSourceSubscriptionFileName -NoCurrent 
Select-AzureSubscription -SubscriptionName $sSourceSubscriptionName -current -SubscriptionDataFile $sSourceSubscriptionFileName 

The result is

SubscriptionId : b6f458b3-0228-48f4-8dec-b7a4884258c6

SubscriptionName : NameOfSubscription

Environment : AzureCloud

SupportedModes : AzureServiceManagement

DefaultAccount : 68BC909D63F2A51F987005620552FB1D643E03DE

Accounts : {68BC909D63F2A51F987005620552FB1D643E03DE}

IsDefault : False

IsCurrent : True

CurrentStorageAccountName : NameOfStorageAccount

I think the JSON format is causing the issue.

2

2 Answers

3
votes

This appears to be a bug that was introduced in v0.8.8 of the Azure PowerShell cmdlets. The bug info is here: https://github.com/Azure/azure-sdk-tools/issues/3045 and a developer from Microsoft has confirmed the problem.

It's not clear whether they're going to fix it though, because the SubscriptionDataFile argument is already marked as deprecated. However, I don't think the proposed new model actually exists yet, so it's not entirely clear what we're supposed to do for now. Using v0.8.7.1 avoids the problem but that doesn't help if you need newer functionality.

0
votes

Hmm. Not sure that's the source of your problem (file in JSON format).

Use Get-AzurePublishSettingsFile to retrieve the XML-based file from the Azure Portal. Then import that file using the Import-AzurePublishSettingsFile Cmdlet.

You may also want to look at the Add-AzureAccount Cmdlet which may be helpful in setting up the credentials for the Cmdlets you're having issues with.