Get / Set-AzureRmContext问题 [英] Get/Set-AzureRmContext issues

查看:67
本文介绍了Get / Set-AzureRmContext问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





最近我们所有的脚本都停止了工作,这似乎是以下问题:



Get-AzureRmContext -ListAvailable



在某些客户端上返回空值:



帐户          : 

SubscriptionName: 

TenantId         : 

环境      : 
$


每当我使用Set-AzureRmContext -SubscriptionName时,上下文永远不会从当前上下文中更改



如果我尝试使用 



$ ctx = Get-AzureRmContext -ListAvailable | ? {$ _。Subscription.Name -match" Name"}

Get-AzureRmStorageAccount -DefaultProfile $ ctx



上下文似乎是被忽略了,这是一个错误还是有些改变了吗?b


PS C:\ Users \ thaaylor> Get-Module -ListAvailable AzureRm



$
   目录:C:\Program Files\WindowsPowerShell\Modules



$
ModuleType Version   名称                                ExportedCommands                           
                                                                         
                                                                         
                                    

---------- -------    ----                                ----------------                           
                                                                         
                                                                         
                                    

脚本      5.2.0      AzureRM                                                         
                                                                         
                                                                         
                                                   

脚本      5.1.1      AzureRM                                                         
                                                                         
                                                                         
                                                   

脚本      5.0.1      AzureRM                              {Add-AzureAnalysisServicesAccount,Add-AzureKeyVaultCertificate,Add-AzureKeyVaultCertificateContact,
Add-AzureKeyVaultKey ...}                                                                   
                                

Hi,

Recently all our scripts have stopped working and it appears to be an issue with the following:

Get-AzureRmContext -ListAvailable

On some clients returns empty values for:

Account          : 
SubscriptionName : 
TenantId         : 
Environment      : 

Whenever I use Set-AzureRmContext -SubscriptionName the context is never changed from the current context

If I try to use 

$ctx = Get-AzureRmContext -ListAvailable | ? {$_.Subscription.Name -match "Name"}
Get-AzureRmStorageAccount -DefaultProfile $ctx

The context seems to be ignored, is this a bug or has something changed in how this works?

PS C:\Users\mtaylor> Get-Module -ListAvailable AzureRm


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands                                                                                                                                                                                                                    
---------- -------    ----                                ----------------                                                                                                                                                                                                                    
Script     5.2.0      AzureRM                                                                                                                                                                                                                                                                 
Script     5.1.1      AzureRM                                                                                                                                                                                                                                                                 
Script     5.0.1      AzureRM                             {Add-AzureAnalysisServicesAccount, Add-AzureKeyVaultCertificate, Add-AzureKeyVaultCertificateContact, Add-AzureKeyVaultKey...}                                                                                                    

推荐答案

注意: 当您在没有使用Azure订阅登录我们的
帐户的情况下运行"Get-AzureRmContext"时,它会提供如下空值:

您必须使用Add-AzureRmAccount通过Azure订阅登录您的帐户,然后我们通过调用Get-AzureRmContext来获取当前会话的上下文。

Add-AzureRmAccount

Add-AzureRmAccount

Get-AzureRmContext

Get-AzureRmContext

OR 使用"Set-AzureRmContext" - 为要在当前会话中使用的cmdlet设置租户,订阅和
环境。

OR Use "Set-AzureRmContext" - Sets the tenant, subscription, and environment for cmdlets to use in the current session.

Set-AzureRmContext -SubscriptionId" xxxx-xxxx-xxxx-xxxx"

Set-AzureRmContext -SubscriptionId "xxxx-xxxx-xxxx-xxxx"

有关详细信息,请参阅" Get-AzureRmContext "和" Set-AzureRmContext "。

For more details, refer "Get-AzureRmContext" and "Set-AzureRmContext".

-------------------------------------------- -------------------------------------------------- -

点击帮助您的帖子上的"标记为答案"和"投票为有用",这可以是
be对其他社区成员有益。

Do click on "Mark as Answer" and "Vote as Helpful" on the post that helps you, this can be beneficial to other community members.


这篇关于Get / Set-AzureRmContext问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆