【问题标题】:Get-AzureStorageAccount Commandlet Returning HttpRequestException返回 HttpRequestException 的获取 AzureStorageAccount 命令行开关
【发布时间】:2014-08-20 13:53:29
【问题描述】:

使用 Azure Powershell 度过了愉快的一天。

经过努力,我已经让一些命令行开关正常工作了,例如Get-AzureSubscription -Current 返回我的订阅的详细信息。

不确定这是否相关,但它返回的详细信息之一是 CurrentStorageAccountName,它是空的。不确定这是否与 Get-AzureStorageAccount commandlet 的目标相同。

Get-AzureStorageAccount 逐字返回以下内容:

Get-AzureStorageAccount :发送请求时出错。 在行:1 字符:1 + 获取 AzureStorageAccount -StorageAccountName "mensch" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ + CategoryInfo : NotSpecified: (:) [Get-AzureStorageAccount], HttpRequestException + FullyQualifiedErrorId:System.Net.Http.HttpRequestException,Microsoft.WindowsAzure.Commands.ServiceManagement.S torageServices.GetAzureStorageAccountCommand

我假设当我之前运行 Set-AzureSubscription commandlet 时它成功了,但它没有给出任何消息。但是我上传了一个证书并使用相关的指纹运行了该命令,并认为我正在路上。

任何想法为什么 Get-AzureStorageAccount 不适合我?

【问题讨论】:

    标签: azure azure-storage azure-powershell


    【解决方案1】:
    I am not sure of the exact sequence of steps you have followed so listing the steps that I followed on a clean environment
    // Get the subscription file. This should open a browser and give you an option to download the settings file
    PS C:\> Get-AzurePublishSettingsFile
    
    // Import the file that was downloaded
    PS C:\> Import-AzurePublishSettingsFile  C:\Temp\settings.publishsettings
    
    
    PS C:\> Get-AzureSubscription -Current
    SubscriptionName                         : <snip>
    SubscriptionId                           : <snip>
    ServiceEndpoint                          : https://management.core.windows.net/
    ResourceManagerEndpoint                  :
    GalleryEndpoint                          :
    ActiveDirectoryEndpoint                  :
    ActiveDirectoryTenantId                  :
    ActiveDirectoryServiceEndpointResourceId :
    SqlDatabaseDnsSuffix                     : <snip>
    IsDefault                                : True
    Certificate                              : <snip>
    CurrentStorageAccountName                :
    ActiveDirectoryUserId                    :
    TokenProvider                            : <snip>
    
    
    // This retrieves the storage account  detils
    PS C:\> Get-AzureStorageAccount
    VERBOSE: 11:28:12 PM - Begin Operation: Get-AzureStorageAccount
    VERBOSE: 11:28:13 PM - Completed Operation: Get-AzureStorageAccount
    
    
    StorageAccountDescription :
    AffinityGroup             :
    Location                  : West US
    GeoReplicationEnabled     : True
    GeoPrimaryLocation        : West US
    GeoSecondaryLocation      : East US
    Label                     : <snip>
    StorageAccountStatus      : Created
    StatusOfPrimary           : Available
    StatusOfSecondary         : Available
    Endpoints                 : <snip>
    StorageAccountName        : <snip>
    OperationDescription      : Get-AzureStorageAccount
    OperationId               : <snip>
    OperationStatus           : Succeeded
    

    偶然发现一个列出步骤的博客 http://blogs.msdn.com/b/umits/archive/2012/11/16/manage-your-windows-azure-with-powershell.aspx

    【讨论】:

    • 我今天登录并运行命令,没有错误。但是,它会返回错误订阅的详细信息。我有一个正在使用的试用订阅,还有一个工作订阅。我再次导入了 PublishFile 设置以进行试用。我再次设置了证书,但它仍然点击了错误的订阅。
    • 请注意,Get-AzureSubscription 返回正确的订阅详细信息。但 Get-AzureStorageAccount 没有。
    • 好的,我设法让它停止显示工作订阅,方法是打开 appdata 中的 WindowsAzureProfile 文件并删除该订阅的订阅元素,只留下我的试用订阅。但是现在出现“服务器无法验证请求”的新错误。
    【解决方案2】:

    我重新开始,我认为问题可能出在我制作证书的方式上。我之前使用 SelfSSL 创建它。

    这一次,我运行了以下命令:

    makecert -sky exchange -r -n "CN=name of cert" -pe -a sha1 -len 2048 -ss My "E:\AzureCert.cer"
    

    不知道为什么这会有所作为。

    【讨论】:

      【解决方案3】:

      这可能是身份验证问题。使用无效的管理证书进行连接时,我看到了同样的、相当无用的错误。使用 Fiddler,我可以看到 Azure 返回 403(禁止)。确保您拥有有效的管理证书。

      您可以执行以下步骤来设置与 Azure 的证书/连接。这是 Import-AzurePublishSettingsFile 方法的替代方法。

      1. Get a msgmt cert for the subscription
      2. Upload the cert to Azure if not already
      3. Install the cert into the local computer store (My)
      4. Run the following:
      
      $subID = "<replaceWithYourId>"
      $thumbprint = "<replaceWithYourThumbprint>"
      $myCert = Get-Item cert:\LocalMachine\My\$thumbprint
      $localSubName = "<replaceWithYourSubscriptionName>"
      
              Set-AzureSubscription –SubscriptionName $localSubName –SubscriptionId $subID -Certificate $myCert
      
              $defaultStorageAccount = '<replaceWithYourStorageAccountName>'
              Set-AzureSubscription -SubscriptionName $localSubName -CurrentStorageAccount   $defaultStorageAccount
      
              Select-AzureSubscription -SubscriptionName $localSubName
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-04-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-06-17
        • 1970-01-01
        • 2011-11-12
        相关资源
        最近更新 更多