2017-10-06 98 views
1

你好我試圖使Web角色的診斷,從而使Web角色診斷,但是當運行腳本,我得到了以下錯誤 https://docs.microsoft.com/en-us/azure/cloud-services/cloud-services-dotnet-diagnostics無法使用PowerShell

$storage_name = "testdeploy" 
$key = "keyvalue" 
$config_path="E:\Tempvs\AzureCloudService3\AzureCloudService3\bin\Release\app.publish\Extensions\PaaSDiagnostics.MvcWebRole1.PubConfig.xml" 
$service_name="testmyjsdiag" 
$storageContext = New-AzureStorageContext -StorageAccountName $storage_name -StorageAccountKey $key 
Set-AzureServiceDiagnosticsExtension -StorageContext $storageContext -DiagnosticsConfigurationPath $config_path -ServiceName $service_name -Slot Production -Role MvcWebRole1 

集-AzureServiceDiagnosticsExtension:不能綁定參數 'StorageContext'。不能 型「Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext」的 「Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext」值轉換爲 型 「Microsoft.WindowsAzure.Commands.Common.Storage.AzureStorageContext」。 在E:\ TK_Backup \ Drive \ PowerShell腳本\啓用Web角色 Diagnostics.ps1:6 char:54 + ... reServiceDiagnosticsExtension -StorageContext $ storageContext -Diagno ... + ~~~~~~~~~ ~~~~~~ + CategoryInfo:InvalidArgument:(:) [設置AzureServiceDiagnosticsExtension],ParameterBindingException + FullyQualifiedErrorId:CannotConvertArgumentNoMessage,Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions.SetAzureServiceDiagnosticsExtensionCommand

回答

3

這似乎是一個已知的問題,所有這些參數應該已經更改爲通用接口類型IStorageContext,以便它們獨立於sto憤怒賬戶版本。

作爲一種變通方法,我們可以使用Set-AzureServiceDiagnosticsExtension cmdlet的使用-StorageAccountName-StorageAccountKey,像這樣:

Set-AzureServiceDiagnosticsExtension -StorageAccountName $storage_name -StorageAccountKey $key 

此外,我們可以使用這個腳本來獲取上下文:

$StorageAccount= Get-AzureStorageAccount -Name "YouStorageAccount" 
$context= $StorageAccount.Context 

這裏一類似的情況請參考it