Azure PowerShell Cmdlets and Setting Service Diagnostics (Set-AzureServiceDiagnosticsExtension)

2k Views Asked by At

Since we updated to Azure SKD 2.5 we can no longer update diagnostics configuration on role start. We instead are now using the Microsoft Azure PowerShell Cmdlets to update our web and worker role diagnostic configuration.

When developing our configuration script we noticed that calling Set-AzureServiceDiagnosticsExtension without first calling Remove-AzureServiceDiagnosticsExtension would fail with the following error:

VERBOSE: Setting default PaaSDiagnostics configuration for all roles.
VERBOSE: 10:01:19 AM - Begin Operation: Set-AzureServiceDiagnosticsExtension
Set-AzureServiceDiagnosticsExtension : BadRequest: Cannot add extension 'Default-PaaSDiagnostics-Production-Ext-0'
with same name space 'Microsoft.Azure.Diagnostics' and type 'PaaSDiagnostics' more than once.
At C:\Github\cloud-build\lib\UpdateDiagnosticsBuildStep.ps1:109 char:7
+       Set-AzureServiceDiagnosticsExtension -StorageContext $storageContext -Diag ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Set-AzureServiceDiagnosticsExtension], CloudException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions.SetAzureServiceDiagnosticsE
   xtensionCommand

Ideally we could just call set to update the existing configuration. Is there a better way to do this that would not require us to have to call remove and set?

We have also noticed that our overall deploy time has roughly doubled as a result of updating the diagnostic configuration via powershell vs on role start. I think the increase can mostly be attributed to the roles restarting when the configuration is updated. Is there a way to avoid this?

Thanks!

2

There are 2 best solutions below

2
On BEST ANSWER

Make sure you add -Role parameter when calling Set-AzureServiceDiagnosticsExtension.

As Saurabh Bhatia pointed it out in a comment @Windows Azure Diagnostics – Upgrading from Azure SDK 2.4 to Azure SDK 2.5,

For the Powershell Script please make sure to explicitly pass in a -Role when you set the extension. If an extension already exists and if you don't pass in the role explicitly then you may see the error mentioned.

Similarly when you remove the extension make sure to explicitly pass in the -role from which you want to remove the extension.

If no diagnostic extension is present on any of the roles then you can call the set extension ps without the Role to set the extension on all roles.

0
On

As Kevin Williamson [MSFT] describes in his blog post:

When you do post-deployment updates to the WAD configuration using Visual Studio it is first downloading the extension configuration using Get Extension API to get the current config, then Add Extension API to update a new config, then Change Deployment Configuration to associate the new extension config to the service, and then Delete Extension to delete the old extension configuration.

http://blogs.msdn.com/b/kwill/archive/2014/12/02/windows-azure-diagnostics-upgrading-from-azure-sdk-2-4-to-azure-sdk-2-5.aspx