Set-AzureServiceDiagnosticsExtension 失败 "Deployment not found in service"

Set-AzureServiceDiagnosticsExtension fails with "Deployment not found in service"

我正在尝试使用以下命令更新 Azure 云服务的诊断配置...

$storage = New-AzureStorageContext -StorageAccountName {storageName} -StorageAccountKey {storage key}
Set-AzureServiceDiagnosticsExtension -ServiceName MyCloudServiceName -StorageContext $storage -Role {my role name} -Slot Production -DiagnosticsConfigurationPath MyWorkerRoleContent\diagnosticsUAT.wadcfgx

失败并出现以下错误...

Set-AzureServiceDiagnosticsExtension : Deployment not found in service: MyCloudServiceName and slot: Production. At line:1 char:1 + Set-AzureServiceDiagnosticsExtension -ServiceName MyCloudServiceName ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Set-AzureServiceDiagnosticsExtension], Exception + FullyQualifiedErrorId : System.Exception,Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions.SetAzureSe rviceDiagnosticsExtensionCommand

我实际上已经使用完全相同的命令取得了成功,但使用的是另一个 Azure 订阅(显然是不同的云服务名称和密钥)。我试过创建一个暂存槽并在暂存槽上使用命令。我也试过完全省略插槽,结果都是一样的。

有没有人遇到过这个问题并且对如何纠正它有任何见解?

此问题也已发布在 GitHub 上,它已得到解决,请参见此处: https://github.com/Azure/azure-powershell/issues/2538#issuecomment-229822864

该问题与在 PowerShell 中注册多个 Azure 订阅有关。

当您 运行 添加 AzureAccount 时,PowerShell 会永久保留凭据。您可以关闭 PowerShell、注销计算机、关闭计算机等,PowerShell 保留对订阅的访问权限。这是我没想到的。

同样在 运行 添加 AzureAccount 之后,如果其他订阅已经注册,您将无法访问添加的订阅中的资源,直到您使用 [=10 选择它作为默认值=].