你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Set-AzureSubscription
更改 Azure 订阅。
注意
本文档中引用的 cmdlet 用于管理使用 Azure Service Manager (ASM) API 的旧式 Azure 资源。 创建新资源时,建议不要使用旧的 PowerShell 模块,因为计划将停用 ASM。 有关详细信息,请参阅 Azure Service Manager 停用。
Az PowerShell 模块是建议用于管理 PowerShell 的 Azure 资源管理器 (ARM) 资源的 PowerShell 模块。
语法
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>]
说明
Set-AzureSubscription cmdlet 建立并更改 Azure 订阅对象的属性。 可以使用此 cmdlet 在不是默认订阅或更改当前存储帐户的 Azure 订阅中工作。 有关当前订阅和默认订阅的信息,请参阅 Select-AzureSubscription cmdlet。
此 cmdlet 在 Azure 订阅对象上运行,而不是实际的 Azure 订阅。 若要创建和预配 Azure 订阅,请访问 Azure 门户 (https://azure.microsoft.com/)。
此 cmdlet 更改使用 Add-AzureAccount 或 Import-AzurePublishSettingsFile cmdlet 将 Azure 帐户添加到 Windows PowerShell 时创建的订阅数据文件中的数据。
本主题介绍 Microsoft Azure PowerShell 模块的 0.8.10 版本中的 cmdlet。
若要获取正在使用的模块版本,请在 Azure PowerShell 控制台中键入 (Get-Module -Name Azure).Version
。
示例
示例 1:更改现有订阅 1
C:\PS> $thumbprint = <Thumbprint-2>
C:\PS> $differentCert = Get-Item cert:\\CurrentUser\My\$thumbprint
C:\PS> Set-AzureSubscription -SubscriptionName ContosoEngineering -Certificate $differentCert
此示例更改名为 ContosoEngineering 的订阅的证书。
示例 2:更改服务终结点
C:\PS> Set-AzureSubscription -SubscriptionName ContosoEngineering -ServiceEndpoint "https://management.core.contoso.com"
此命令为 ContosoEngineering 订阅添加或更改自定义服务终结点。
示例 3:清除属性值
C:\PS> Set-AzureSubscription -SubscriptionName ContosoEngineering -Certificate $null -ResourceManagerEndpoint $Null
此命令将 Certificate 和 ResourceManagerEndpoint 属性的值设置为 null($Null)。 这会清除这些属性的值,而无需更改其他设置。
示例 4:使用备用订阅数据文件
C:\PS> Set-AzureSubscription -SubscriptionName ContosoFinance -SubscriptionDataFile C:\Azure\SubscriptionData.xml -CurrentStorageAccount ContosoStorage01
此命令将 ContosoFinance 订阅的当前存储帐户更改为 ContosoStorage01。 该命令使用 SubscriptionDataFile 参数更改 C:\Azure\SubscriptionData.xml订阅数据文件中的数据。 默认情况下, Set-AzureSubscription 在漫游用户配置文件中使用默认订阅数据文件。
参数
-Certificate
类型: | X509Certificate2 |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-Context
类型: | AzureStorageContext |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-CurrentStorageAccountName
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Environment
指定 Azure 环境。
Azure 环境独立于 azure 部署Microsoft,例如 AzureCloud for global Azure,以及由世纪互联在中国运营的 AzureChinaCloud for Azure。 还可以使用 Azure Pack 和 WAPack cmdlet 创建本地 Azure 环境。 有关详细信息,请参阅 Azure Pack。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-PassThru
如果命令成功,$False失败,则返回$True。 默认情况下,此 cmdlet 不返回任何输出。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Profile
指定此 cmdlet 从中读取的 Azure 配置文件。 如果未指定配置文件,此 cmdlet 将从本地默认配置文件中读取。
类型: | AzureSMProfile |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ResourceManagerEndpoint
指定 Azure 资源管理器数据的终结点,包括与帐户关联的资源组的相关数据。 有关 Azure 资源管理器的详细信息,请参阅 Azure 资源管理器 Cmdlet (https://go.microsoft.com/fwlink/?LinkID=394765) 和将 Windows PowerShell 与 资源管理器 配合使用(https://go.microsoft.com/fwlink/?LinkID=394767)。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-ServiceEndpoint
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-SubscriptionId
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-SubscriptionName
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
输入
None
可以通过属性名称(而不是值)通过管道将输入传递给此 cmdlet。
输出
None or System.Boolean
使用 PassThru 参数时,此 cmdlet 返回布尔值。 默认情况下,此 cmdlet 不返回任何输出。