title: Azure PowerShell Cmdlets and Setting Service Diagnostics (Set-AzureServiceDiagnosticsExtension)
body: <p>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. </p>
  
  <p>When developing our configuration script we noticed that calling <code>Set-AzureServiceDiagnosticsExtension</code> without first calling <code>Remove-AzureServiceDiagnosticsExtension</code> would fail with the following error:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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?</p>
  
  <p>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?</p>
  
  <p>Thanks!</p>