使用Powershell 添加,选择更改订阅

时间:2023-03-10 05:38:56
使用Powershell 添加,选择更改订阅
PS C:\WINDOWS\system32> Import-AzurePublishSettingsFile 'C:\Users\Ling\Desktop\Free-11-24-2014-credentials.publishsettin
gs' Id : 36b1bd18-6519-4ea5-8d90-5300a6915a25
Name : Free
Environment : AzureChinaCloud
Account : 5499B16B9FEC1DF8608CD
Properties : {[SupportedModes, AzureServiceManagement]} PS C:\WINDOWS\system32>

首先先参考如何使用add-azureaccount加入账户

http://www.cnblogs.com/SignalTips/p/4106248.html

这篇文章介绍了如何使用加入账号使用Powershell访问Azure。

假如有多个订阅,如何进行切换的,如何添加订阅,如何更改默认订阅。

1.如何切换不同订阅

PS C:\WINDOWS\system32> Select-AzureSubscription -SubscriptionName Pay
PS C:\WINDOWS\system32> Get-AzureSubscription -Current SubscriptionId :
SubscriptionName : Pay
Environment : AzureChinaCloud
SupportedModes : AzureServiceManagement
DefaultAccount : Andreson@signalTips.partner.onmschina.cn
Accounts : {Andreson@signalTips.partner.onmschina.cn}
IsDefault : False
IsCurrent : True
CurrentStorageAccountName :

如何获取订阅名称

PS C:\WINDOWS\system32> Get-AzureSubscription

SubscriptionId            :
SubscriptionName : MSDN
Environment : AzureCloud
SupportedModes : AzureServiceManagement,AzureResourceManager
DefaultAccount : anderson.ling@outlook.com
Accounts : {anderson.ling@outlook.com,
}
IsDefault : False
IsCurrent : False
CurrentStorageAccountName : SubscriptionId :
SubscriptionName : Pay
Environment : AzureChinaCloud
SupportedModes : AzureServiceManagement
DefaultAccount : Andreson@signalTips.partner.onmschina.cn
Accounts : {Andreson@signalTips.partner.onmschina.cn}
IsDefault : False
IsCurrent : True
CurrentStorageAccountName : SubscriptionId :
SubscriptionName : Free
Environment : AzureChinaCloud
SupportedModes : AzureServiceManagement
DefaultAccount : Ling@SHTriathlon.partner.onmschina.cn
Accounts : {Ling@SHTriathlon.partner.onmschina.cn,
}
IsDefault : True
IsCurrent : False
CurrentStorageAccountName :

2.如何添加订阅

先使用切换至需要获取订阅的账户,

PS C:\WINDOWS\system32> Select-AzureSubscription -SubscriptionName

使用以下命令,或切换至下载认证的网页

PS C:\WINDOWS\system32> Get-AzurePublishSettingsFile

下载完毕后使用以下方法导入证书

可以在设置下查看到以下信息

使用Powershell 添加,选择更改订阅