Set-AzureSubscription

Changes an Azure subscription.

Note

The cmdlets referenced in this documentation are for managing legacy Azure resources that use Azure Service Manager (ASM) APIs. This legacy PowerShell module isn't recommended when creating new resources since ASM is scheduled for retirement. For more information, see Azure Service Manager retirement.

The Az PowerShell module is the recommended PowerShell module for managing Azure Resource Manager (ARM) resources with PowerShell.

Syntax

Set-AzureSubscription
   -SubscriptionId <String>
   [-Certificate <X509Certificate2>]
   [-ServiceEndpoint <String>]
   [-ResourceManagerEndpoint <String>]
   [-CurrentStorageAccountName <String>]
   [-Context <AzureStorageContext>]
   [-Environment <String>]
   [-PassThru]
   [-Profile <AzureSMProfile>]
   [<CommonParameters>]
Set-AzureSubscription
   -SubscriptionName <String>
   [-Certificate <X509Certificate2>]
   [-ServiceEndpoint <String>]
   [-ResourceManagerEndpoint <String>]
   [-CurrentStorageAccountName <String>]
   [-Context <AzureStorageContext>]
   [-Environment <String>]
   [-PassThru]
   [-Profile <AzureSMProfile>]
   [<CommonParameters>]
Set-AzureSubscription
   -SubscriptionName <String>
   -SubscriptionId <String>
   -Certificate <X509Certificate2>
   [-ServiceEndpoint <String>]
   [-ResourceManagerEndpoint <String>]
   [-CurrentStorageAccountName <String>]
   [-Context <AzureStorageContext>]
   [-Environment <String>]
   [-PassThru]
   [-Profile <AzureSMProfile>]
   [<CommonParameters>]

Description

The Set-AzureSubscription cmdlet establishes and changes the properties of an Azure subscription object. You can use this cmdlet to work in an Azure subscription that is not your default subscription or to change your current storage account. For information about current and default subscriptions, see the Select-AzureSubscription cmdlet.

This cmdlet operates on an Azure subscription object, not your actual Azure subscription. To create and provision an Azure subscription, visit the Azure Portal (https://azure.microsoft.com/).

This cmdlet changes the data in the subscription data file that you create when you use the Add-AzureAccount or Import-AzurePublishSettingsFile cmdlet to add an Azure account to Windows PowerShell.

This topic describes the cmdlet in the 0.8.10 version of the Microsoft Azure PowerShell module. To get the version of the module you're using, in the Azure PowerShell console, type (Get-Module -Name Azure).Version.

Examples

Example 1: Change an existing subscription1

C:\PS> $thumbprint = <Thumbprint-2>
C:\PS> $differentCert = Get-Item cert:\\CurrentUser\My\$thumbprint
C:\PS> Set-AzureSubscription -SubscriptionName ContosoEngineering -Certificate $differentCert

This example changes the certificate for the subscription named ContosoEngineering.

Example 2: Change the service endpoint

C:\PS> Set-AzureSubscription -SubscriptionName ContosoEngineering -ServiceEndpoint "https://management.core.contoso.com"

This command adds or changes a custom service endpoint for the ContosoEngineering subscription.

Example 3: Clear property values

C:\PS> Set-AzureSubscription -SubscriptionName ContosoEngineering -Certificate $null -ResourceManagerEndpoint $Null

This command sets the values of the Certificate and ResourceManagerEndpoint properties to null ($Null). This clears the values of those properties without changing other settings.

Example 4: Use an alternate subscription data file

C:\PS> Set-AzureSubscription -SubscriptionName ContosoFinance -SubscriptionDataFile C:\Azure\SubscriptionData.xml -CurrentStorageAccount ContosoStorage01

This command changes the current storage account of the ContosoFinance subscription to ContosoStorage01. The command uses the SubscriptionDataFile parameter to change the data in the C:\Azure\SubscriptionData.xml subscription data file. By default, Set-AzureSubscription uses the default subscription data file in your roaming user profile.

Parameters

-Certificate

Type:X509Certificate2
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Context

Type:AzureStorageContext
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-CurrentStorageAccountName

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Environment

Specifies an Azure environment.

An Azure environment an independent deployment of Microsoft Azure, such as AzureCloud for global Azure and AzureChinaCloud for Azure operated by 21Vianet in China. You can also create on-premises Azure environments by using Azure Pack and the WAPack cmdlets. For more information, see Azure Pack.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-PassThru

Returns $True if the command succeeds and $False if it fails. By default, this cmdlet does not return any output.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Profile

Specifies the Azure profile from which this cmdlet reads. If you do not specify a profile, this cmdlet reads from the local default profile.

Type:AzureSMProfile
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ResourceManagerEndpoint

Specifies the endpoint for Azure Resource Manager data, including data about resource groups associated with the account. For more information about Azure Resource Manager, see Azure Resource Manager Cmdlets (https://go.microsoft.com/fwlink/?LinkID=394765) and Using Windows PowerShell with Resource Manager (https://go.microsoft.com/fwlink/?LinkID=394767).

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-ServiceEndpoint

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-SubscriptionId

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-SubscriptionName

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

Inputs

None

You can pipe input to this cmdlet by property name, but not by value.

Outputs

None or System.Boolean

When you use the PassThru parameter, this cmdlet returns a Boolean value. By default, this cmdlet does not return any output.