Set-AzureSubscription

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Set-AzureSubscription

Configures and stores common Windows Azure subscription settings.

Parameter Set: CommonSettings
Set-AzureSubscription [-SubscriptionName] <String> [-Certificate <X509Certificate2> ] [-CurrentStorageAccount <String> ] [-PassThru] [-ServiceEndpoint <String> ] [-SubscriptionDataFile <String> ] [-SubscriptionId <String> ] [ <CommonParameters>]

Parameter Set: DefaultSubscription
Set-AzureSubscription -DefaultSubscription <String> [-PassThru] [-SubscriptionDataFile <String> ] [ <CommonParameters>]

Parameter Set: ResetCurrentStorageAccount
Set-AzureSubscription [-SubscriptionName] <String> [-PassThru] [-SubscriptionDataFile <String> ] [ <CommonParameters>]

Parameter Set: ResetDefaultSubscription
Set-AzureSubscription -NoDefaultSubscription [-PassThru] [-SubscriptionDataFile <String> ] [ <CommonParameters>]

This topic describes the cmdlet in the .6.19 version of the Windows Azure PowerShell module. To find out the version of the module you're using, from the Windows Azure PowerShell console, type (get-module azure).version.

The Set-AzureSubscription cmdlet configures common settings including subscription ID, management certificate, and custom endpoints. The settings are stored in a subscription data file in the user’s profile or in a user specified file. Multiple subscription data sets are supported and identified by a subscription name. To select a subscription and make it current, use the Select-AzureSubscription cmdlet.

Use the Set-AzureSubscription cmdlet to store the management certificate associated with a subscription. The management certificates specified for a subscription must be accessible and installed locally in the user's personal certificate store, or in the local machine’s personal certificate store.

The service endpoint is the Windows Azure management API endpoint for the target environment. Custom service endpoints are supported and can be different for each configured subscription.

Each subscription data set can contain information for the current Windows Azure Storage account. Storage account information is set with the CurrentStorageAccount parameter.

All connection information is stored in encrypted form in the subscription data file. If a subscription is designated as the default subscription, it is automatically made current when starting a Windows PowerShell session or running a script. To set the default subscription, use the DefaultSubscription parameter and specify the name of the subscription to designate as the default. The default subscription setting can be cleared by specifying the NoDefaultSubscription switch parameter.

All the parameters required to initialize a subscription are optional. Whenever a Windows Azure PowerShell cmdlet is run, it retrieves its default settings from the current subscription data. If a setting is not part of the current subscription data, specify it as an explicit command line parameter.

-Certificate<X509Certificate2>

The account management certificate associated with the subscription. Management certificates are X.509 certificates that are saved as .cer files and uploaded to the Windows Azure Management Portal. The certificate, including its private key, must be installed on the local computer, either in the current user's personal certificate store, or the local machine’s personal certificate store.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-CurrentStorageAccount<String>

The storage account to use for the subscription.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DefaultSubscription<String>

Designates a subscription as the default subscription. A default subscription is automatically made current when the Windows PowerShell session starts.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-NoDefaultSubscription

Resets the current default subscription setting. If no default subscription is defined, you will need to run Select-AzureSubscription to choose the current subscription.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PassThru

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ServiceEndpoint<String>

Specifies a custom service endpoint for the management service in the target environment (Advanced).

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-SubscriptionDataFile<String>

Specifies the path to the file in which subscription data is stored. This parameter is optional. If not specified, subscription data is stored in a default subscription data file in the user's profile.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-SubscriptionId<String>

Specifies the ID of the subscription. Each Windows Azure subscription is uniquely identified by a subscription ID. You can retrieve this ID from the Windows Azure Management Portal.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-SubscriptionName<String>

The name of the subscription data set that will be updated.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see  about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

Example 1

These commands set common parameters including a subscription ID and certificate for the "MySub" subscription.

C:\PS> $subID = <Subscription ID>
C:\PS>$thumbprint = <Certificate Thumbprint> 
C:\PS>$myCert = Get-Item cert:\\CurrentUser\My\$thumbprint 
C:\PS> Set-AzureSubscription –SubscriptionName "MySub" -SubscriptionId $subID -Certificate $myCert 

Example 2

These commands configure first a subscription ID and then a certificate for the "MySub" subscription. It is equivalent to the previous example.

C:\PS> $subID = <Subscription ID>
C:\PS>$thumbprint = <Certificate Thumbprint> 
C:\PS>$myCert = Get-Item cert:\\CurrentUser\My\$thumbprint 
C:\PS> Set-AzureSubscription –SubscriptionName "MySub" –SubscriptionId $subID 
C:\PS> Set-AzureSubscription –SubscriptionName "MySub" –Certificate $myCert

Example 3

This command configures a custom service endpoint for the "MySub" subscription.

C:\PS> Set-AzureSubscription –SubscriptionName "MySub" -ServiceEndpoint "https://management.core.windows-internal.net"

Example 4

This command clears the settings for the certificate and custom service endpoint in the "MySub" subscription without changing other settings.

C:\PS> Set-AzureSubscription –SubscriptionName "MySub" –Certificate $null -ServiceEndpoint $null

Example 5

This command initializes the subscription ID and certificate for a subscription named "TestSub" and stores them in the specified subscription data file.

C:\PS> $subID = <Subscription ID>
C:\PS>$thumbprint = <Certificate Thumbprint> 
C:\PS> $myCert = Get-Item cert:\\CurrentUser\My\$thumbprint 
C:\PS> Set-AzureSubscription –SubscriptionName "TestSub" –SubscriptionId $subID -Certificate $myCert -SubscriptionDataFile "C:\temp\mysubscriptiondatafile.xml" 

Example 6

This command adds a current storage account to the "MySub" subscription.

C:\PS> Set-AzureSubscription –SubscriptionName "MySub" -CurrentStorageAccount mystorage1 

Example 7

This command designates "MySub" as the default subscription.

C:\PS> Set-AzureSubscription –DefaultSubscription "MySub" 

Example 8

This command resets the default subscription setting.

C:\PS>Set-AzureSubscription –NoDefaultSubscription 

Get-AzureSubscription

Remove-AzureSubscription

Select-AzureSubscription

Import-AzurePublishSettingsFile

Get Started with Windows Azure Cmdlets