1
votes

Hi I am trying to enable the diagnostics for web role but when ran the script I got the below error https://docs.microsoft.com/en-us/azure/cloud-services/cloud-services-dotnet-diagnostics

$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

Set-AzureServiceDiagnosticsExtension : Cannot bind parameter 'StorageContext'. Cannot convert the "Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext" value of type "Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext" to type "Microsoft.WindowsAzure.Commands.Common.Storage.AzureStorageContext". At E:\TK_Backup\Drive\PowerShell Scripts\Enable Web Role Diagnostics.ps1:6 char:54 + ... reServiceDiagnosticsExtension -StorageContext $storageContext -Diagno ... + ~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Set-AzureServiceDiagnosticsExtension], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions.SetAzureServiceDiagnosticsExtensionCommand

1

1 Answers

3
votes

It seems a known issue, all such parameters should have been changed to the common interface type IStorageContext, so that they are independent of the storage account version.

As a workaround, we can use Set-AzureServiceDiagnosticsExtension cmdlet by using the -StorageAccountName and -StorageAccountKey, like this:

Set-AzureServiceDiagnosticsExtension -StorageAccountName $storage_name -StorageAccountKey $key

Also we can use this script to get the context:

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

Here a similar case, please refer to it.