Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 获取Azure Automation上的AzureStorageKey错误_Powershell_Azure_Azure Automation - Fatal编程技术网

Powershell 获取Azure Automation上的AzureStorageKey错误

Powershell 获取Azure Automation上的AzureStorageKey错误,powershell,azure,azure-automation,Powershell,Azure,Azure Automation,我正在使用“经典RunAs连接”配置Azure自动化Runbook。 在我通过此连接选择Azure订阅后,我将获得我的一个存储帐户的存储密钥,但问题是,它有时有效,有时无效。以下是我正在做的: $ConnectionAssetName = "AzureClassicRunAsConnection" $Conn = Get-AutomationConnection -Name $ConnectionAssetName $CertificateAssetName = $Conn.Certifica

我正在使用“经典RunAs连接”配置Azure自动化Runbook。 在我通过此连接选择Azure订阅后,我将获得我的一个存储帐户的存储密钥,但问题是,它有时有效,有时无效。以下是我正在做的:

$ConnectionAssetName = "AzureClassicRunAsConnection" 
$Conn = Get-AutomationConnection -Name $ConnectionAssetName
$CertificateAssetName = $Conn.CertificateAssetName
$Cert = Get-AutomationCertificate -Name $CertificateAssetName 
Set-AzureSubscription -SubscriptionName $Conn.SubscriptionName -SubscriptionId $Conn.SubscriptionID -Certificate $AzureCert  
Select-AzureSubscription -SubscriptionId $Conn.SubscriptionID

$storageAccountKey = Get-AzureStorageKey -StorageAccountName "MyStorageAccountName" 
发生的瞬时误差为:

Get-AzureStorageKey:发送请求时出错

第38行字符:26

  • 。。。eAccountKey=Get AzureStorageKey-StorageAccountName“MyStorageAccountName”

  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    • CategoryInfo:CloseError:(:)[Get-AzureStorageKey],HttpRequestException

    • FullyQualifiedErrorId:

Microsoft.WindowsAzure.Commands.ServiceManagement.StorageServices.GetAzureStorageKeyCommand

它大部分时间都有效,但有时会引发此异常

有人能帮我吗


谢谢

您需要使用RunAs连接-ClassCrunasConnections用于RDFE,KeyVault cmdlet使用您的AzureRm凭据。RunAs凭据为您提供了一个服务主体,您需要在KeyVault配置中为该服务主体提供对KeyVault的访问权限

在一些不成功的测试之后,我决定将StorageKey存储在一个加密变量中

我知道这不是最好的解决方案,但我没有发现问题所在。
最初的解决方案大部分时间都有效,但错误发生时引发的异常无法帮助我找到它。

您能告诉我您的存储帐户是哪种类型的吗?ASM还是ARM?嗨,杰森!这是一个ASM帐户(经典)。谢谢马克!Get-AzureStorageKey cmdlet是否使用KeyVault?我认为“ClassCrunasConnection”是连接经典存储帐户的正确选择,但我会按照您的建议,使用“AzureRunAsConnection”进行一些测试。然而,这很奇怪,因为它有时有效,有时无效。谢谢,这完全是关于获取AzureKeyVaultSecret或获取AzureKeyVaultKey的。Get-AzureStorageKey是一个RDFE cmdlet