azure runbook enable guest level diagnostics












0















I am working on a PowerShell runbook to look at all vms in the azure subscription, find out if guest level monitoring is not enabled and enable it



Following is the command I am using to enable the diags.



Set-AzureRmVMDiagnosticsExtension -ResourceGroupName xxxxxx -VMName xxxxxx -DiagnosticsConfigurationPath $diagnosticsconfig_path -StorageAccountName xxxxxx


I am thinking of storing the diag xml file in a storage blog, how do I point to it with $diagnosticsconfig_path ?



If I use



Get-AzureStorageBlobContent -blob "xxx.json" -Container xxx -Context $storageAccount.Context 

or

Get-AzureStorageFileContent -ShareName 'xxx' -Context $storageAccount.Context -path xxx.json


The runbook can download the file but how do I refer to this file as the diagpath in Set-AzureRmVMDiagnosticsExtension










share|improve this question



























    0















    I am working on a PowerShell runbook to look at all vms in the azure subscription, find out if guest level monitoring is not enabled and enable it



    Following is the command I am using to enable the diags.



    Set-AzureRmVMDiagnosticsExtension -ResourceGroupName xxxxxx -VMName xxxxxx -DiagnosticsConfigurationPath $diagnosticsconfig_path -StorageAccountName xxxxxx


    I am thinking of storing the diag xml file in a storage blog, how do I point to it with $diagnosticsconfig_path ?



    If I use



    Get-AzureStorageBlobContent -blob "xxx.json" -Container xxx -Context $storageAccount.Context 

    or

    Get-AzureStorageFileContent -ShareName 'xxx' -Context $storageAccount.Context -path xxx.json


    The runbook can download the file but how do I refer to this file as the diagpath in Set-AzureRmVMDiagnosticsExtension










    share|improve this question

























      0












      0








      0








      I am working on a PowerShell runbook to look at all vms in the azure subscription, find out if guest level monitoring is not enabled and enable it



      Following is the command I am using to enable the diags.



      Set-AzureRmVMDiagnosticsExtension -ResourceGroupName xxxxxx -VMName xxxxxx -DiagnosticsConfigurationPath $diagnosticsconfig_path -StorageAccountName xxxxxx


      I am thinking of storing the diag xml file in a storage blog, how do I point to it with $diagnosticsconfig_path ?



      If I use



      Get-AzureStorageBlobContent -blob "xxx.json" -Container xxx -Context $storageAccount.Context 

      or

      Get-AzureStorageFileContent -ShareName 'xxx' -Context $storageAccount.Context -path xxx.json


      The runbook can download the file but how do I refer to this file as the diagpath in Set-AzureRmVMDiagnosticsExtension










      share|improve this question














      I am working on a PowerShell runbook to look at all vms in the azure subscription, find out if guest level monitoring is not enabled and enable it



      Following is the command I am using to enable the diags.



      Set-AzureRmVMDiagnosticsExtension -ResourceGroupName xxxxxx -VMName xxxxxx -DiagnosticsConfigurationPath $diagnosticsconfig_path -StorageAccountName xxxxxx


      I am thinking of storing the diag xml file in a storage blog, how do I point to it with $diagnosticsconfig_path ?



      If I use



      Get-AzureStorageBlobContent -blob "xxx.json" -Container xxx -Context $storageAccount.Context 

      or

      Get-AzureStorageFileContent -ShareName 'xxx' -Context $storageAccount.Context -path xxx.json


      The runbook can download the file but how do I refer to this file as the diagpath in Set-AzureRmVMDiagnosticsExtension







      powershell automation azure-devops azure-storage azure-runbook






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 20 '18 at 12:23









      DebDeb

      32




      32
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Try the command below, you are no need to download the file, we can point the path directly to the blob url.



          $SAResourceGroupName="<Storage Account ResourceGroupName>"
          $StorageAccountName="<StorageAccountName>"

          $StorageAccountKey = (Get-AzureRmStorageAccountKey -ResourceGroupName $SAResourceGroupName -AccountName $StorageAccountName).Value[1]
          $Context=New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey

          $tmpStart = Get-Date
          $tmpEnd = $tmpStart.AddHours(2.0)
          $SASToken = New-AzureStorageBlobSASToken -Blob "diagnostics_publicconfig.xml" -Container "111" -Context $Context -Permission r -StartTime $tmpStart -ExpiryTime $tmpEnd -FullURI

          Set-AzureRmVMDiagnosticsExtension -ResourceGroupName joywebapp -VMName joyVM -DiagnosticsConfigurationPath "$SASToken" -StorageAccountName joystoragev2


          enter image description here



          In the runbook:



          enter image description here






          share|improve this answer


























          • Thanks Joy for the response, Following is what I am getting when I try the script Set-AzureRmVMDiagnosticsExtension : Illegal characters in path. I tried something similar before by manually created the SAS and fed it to variable $diagnosticsconfig_path and it gave me same error.

            – Deb
            Nov 21 '18 at 12:22













          • @Deb I test it in the runbook, it also works, see my update, could you provide your specific command? especially the -DiagnosticsConfigurationPath you used.

            – Joy Wang
            Nov 22 '18 at 5:47











          • $SASToken = New-AzureStorageBlobSASToken -Blob "GLD.json" -Container "scripts" -Context $Context -Permission r -StartTime $tmpStart -ExpiryTime $tmpEnd -FullURI Set-AzureRmVMDiagnosticsExtension -ResourceGroupName deb_nonprod -VMName AZINF3001 -DiagnosticsConfigurationPath $SASToken -StorageAccountName nonproddiag980

            – Deb
            Nov 22 '18 at 10:24













          • I tried in Azure runbook too and it gave me same error. Does it matter if the storage blob has more than 1 file in it?

            – Deb
            Nov 22 '18 at 10:58






          • 1





            yes that worked, wonder y it didn't work as .json. However what I did for the xml is copied the sample xml from https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/diagnostics-windows changed the resource id and storageaccount and applied it. Applied fine, but now when I try to change the settings in the portal (eg. Sample rate of processor time) it says Update failed . Also in this case for every VM I will need a separate xml, thats gona be a pain.

            – Deb
            Nov 23 '18 at 12:40











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53392917%2fazure-runbook-enable-guest-level-diagnostics%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Try the command below, you are no need to download the file, we can point the path directly to the blob url.



          $SAResourceGroupName="<Storage Account ResourceGroupName>"
          $StorageAccountName="<StorageAccountName>"

          $StorageAccountKey = (Get-AzureRmStorageAccountKey -ResourceGroupName $SAResourceGroupName -AccountName $StorageAccountName).Value[1]
          $Context=New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey

          $tmpStart = Get-Date
          $tmpEnd = $tmpStart.AddHours(2.0)
          $SASToken = New-AzureStorageBlobSASToken -Blob "diagnostics_publicconfig.xml" -Container "111" -Context $Context -Permission r -StartTime $tmpStart -ExpiryTime $tmpEnd -FullURI

          Set-AzureRmVMDiagnosticsExtension -ResourceGroupName joywebapp -VMName joyVM -DiagnosticsConfigurationPath "$SASToken" -StorageAccountName joystoragev2


          enter image description here



          In the runbook:



          enter image description here






          share|improve this answer


























          • Thanks Joy for the response, Following is what I am getting when I try the script Set-AzureRmVMDiagnosticsExtension : Illegal characters in path. I tried something similar before by manually created the SAS and fed it to variable $diagnosticsconfig_path and it gave me same error.

            – Deb
            Nov 21 '18 at 12:22













          • @Deb I test it in the runbook, it also works, see my update, could you provide your specific command? especially the -DiagnosticsConfigurationPath you used.

            – Joy Wang
            Nov 22 '18 at 5:47











          • $SASToken = New-AzureStorageBlobSASToken -Blob "GLD.json" -Container "scripts" -Context $Context -Permission r -StartTime $tmpStart -ExpiryTime $tmpEnd -FullURI Set-AzureRmVMDiagnosticsExtension -ResourceGroupName deb_nonprod -VMName AZINF3001 -DiagnosticsConfigurationPath $SASToken -StorageAccountName nonproddiag980

            – Deb
            Nov 22 '18 at 10:24













          • I tried in Azure runbook too and it gave me same error. Does it matter if the storage blob has more than 1 file in it?

            – Deb
            Nov 22 '18 at 10:58






          • 1





            yes that worked, wonder y it didn't work as .json. However what I did for the xml is copied the sample xml from https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/diagnostics-windows changed the resource id and storageaccount and applied it. Applied fine, but now when I try to change the settings in the portal (eg. Sample rate of processor time) it says Update failed . Also in this case for every VM I will need a separate xml, thats gona be a pain.

            – Deb
            Nov 23 '18 at 12:40
















          0














          Try the command below, you are no need to download the file, we can point the path directly to the blob url.



          $SAResourceGroupName="<Storage Account ResourceGroupName>"
          $StorageAccountName="<StorageAccountName>"

          $StorageAccountKey = (Get-AzureRmStorageAccountKey -ResourceGroupName $SAResourceGroupName -AccountName $StorageAccountName).Value[1]
          $Context=New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey

          $tmpStart = Get-Date
          $tmpEnd = $tmpStart.AddHours(2.0)
          $SASToken = New-AzureStorageBlobSASToken -Blob "diagnostics_publicconfig.xml" -Container "111" -Context $Context -Permission r -StartTime $tmpStart -ExpiryTime $tmpEnd -FullURI

          Set-AzureRmVMDiagnosticsExtension -ResourceGroupName joywebapp -VMName joyVM -DiagnosticsConfigurationPath "$SASToken" -StorageAccountName joystoragev2


          enter image description here



          In the runbook:



          enter image description here






          share|improve this answer


























          • Thanks Joy for the response, Following is what I am getting when I try the script Set-AzureRmVMDiagnosticsExtension : Illegal characters in path. I tried something similar before by manually created the SAS and fed it to variable $diagnosticsconfig_path and it gave me same error.

            – Deb
            Nov 21 '18 at 12:22













          • @Deb I test it in the runbook, it also works, see my update, could you provide your specific command? especially the -DiagnosticsConfigurationPath you used.

            – Joy Wang
            Nov 22 '18 at 5:47











          • $SASToken = New-AzureStorageBlobSASToken -Blob "GLD.json" -Container "scripts" -Context $Context -Permission r -StartTime $tmpStart -ExpiryTime $tmpEnd -FullURI Set-AzureRmVMDiagnosticsExtension -ResourceGroupName deb_nonprod -VMName AZINF3001 -DiagnosticsConfigurationPath $SASToken -StorageAccountName nonproddiag980

            – Deb
            Nov 22 '18 at 10:24













          • I tried in Azure runbook too and it gave me same error. Does it matter if the storage blob has more than 1 file in it?

            – Deb
            Nov 22 '18 at 10:58






          • 1





            yes that worked, wonder y it didn't work as .json. However what I did for the xml is copied the sample xml from https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/diagnostics-windows changed the resource id and storageaccount and applied it. Applied fine, but now when I try to change the settings in the portal (eg. Sample rate of processor time) it says Update failed . Also in this case for every VM I will need a separate xml, thats gona be a pain.

            – Deb
            Nov 23 '18 at 12:40














          0












          0








          0







          Try the command below, you are no need to download the file, we can point the path directly to the blob url.



          $SAResourceGroupName="<Storage Account ResourceGroupName>"
          $StorageAccountName="<StorageAccountName>"

          $StorageAccountKey = (Get-AzureRmStorageAccountKey -ResourceGroupName $SAResourceGroupName -AccountName $StorageAccountName).Value[1]
          $Context=New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey

          $tmpStart = Get-Date
          $tmpEnd = $tmpStart.AddHours(2.0)
          $SASToken = New-AzureStorageBlobSASToken -Blob "diagnostics_publicconfig.xml" -Container "111" -Context $Context -Permission r -StartTime $tmpStart -ExpiryTime $tmpEnd -FullURI

          Set-AzureRmVMDiagnosticsExtension -ResourceGroupName joywebapp -VMName joyVM -DiagnosticsConfigurationPath "$SASToken" -StorageAccountName joystoragev2


          enter image description here



          In the runbook:



          enter image description here






          share|improve this answer















          Try the command below, you are no need to download the file, we can point the path directly to the blob url.



          $SAResourceGroupName="<Storage Account ResourceGroupName>"
          $StorageAccountName="<StorageAccountName>"

          $StorageAccountKey = (Get-AzureRmStorageAccountKey -ResourceGroupName $SAResourceGroupName -AccountName $StorageAccountName).Value[1]
          $Context=New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey

          $tmpStart = Get-Date
          $tmpEnd = $tmpStart.AddHours(2.0)
          $SASToken = New-AzureStorageBlobSASToken -Blob "diagnostics_publicconfig.xml" -Container "111" -Context $Context -Permission r -StartTime $tmpStart -ExpiryTime $tmpEnd -FullURI

          Set-AzureRmVMDiagnosticsExtension -ResourceGroupName joywebapp -VMName joyVM -DiagnosticsConfigurationPath "$SASToken" -StorageAccountName joystoragev2


          enter image description here



          In the runbook:



          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 22 '18 at 5:45

























          answered Nov 21 '18 at 6:30









          Joy WangJoy Wang

          6,8732213




          6,8732213













          • Thanks Joy for the response, Following is what I am getting when I try the script Set-AzureRmVMDiagnosticsExtension : Illegal characters in path. I tried something similar before by manually created the SAS and fed it to variable $diagnosticsconfig_path and it gave me same error.

            – Deb
            Nov 21 '18 at 12:22













          • @Deb I test it in the runbook, it also works, see my update, could you provide your specific command? especially the -DiagnosticsConfigurationPath you used.

            – Joy Wang
            Nov 22 '18 at 5:47











          • $SASToken = New-AzureStorageBlobSASToken -Blob "GLD.json" -Container "scripts" -Context $Context -Permission r -StartTime $tmpStart -ExpiryTime $tmpEnd -FullURI Set-AzureRmVMDiagnosticsExtension -ResourceGroupName deb_nonprod -VMName AZINF3001 -DiagnosticsConfigurationPath $SASToken -StorageAccountName nonproddiag980

            – Deb
            Nov 22 '18 at 10:24













          • I tried in Azure runbook too and it gave me same error. Does it matter if the storage blob has more than 1 file in it?

            – Deb
            Nov 22 '18 at 10:58






          • 1





            yes that worked, wonder y it didn't work as .json. However what I did for the xml is copied the sample xml from https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/diagnostics-windows changed the resource id and storageaccount and applied it. Applied fine, but now when I try to change the settings in the portal (eg. Sample rate of processor time) it says Update failed . Also in this case for every VM I will need a separate xml, thats gona be a pain.

            – Deb
            Nov 23 '18 at 12:40



















          • Thanks Joy for the response, Following is what I am getting when I try the script Set-AzureRmVMDiagnosticsExtension : Illegal characters in path. I tried something similar before by manually created the SAS and fed it to variable $diagnosticsconfig_path and it gave me same error.

            – Deb
            Nov 21 '18 at 12:22













          • @Deb I test it in the runbook, it also works, see my update, could you provide your specific command? especially the -DiagnosticsConfigurationPath you used.

            – Joy Wang
            Nov 22 '18 at 5:47











          • $SASToken = New-AzureStorageBlobSASToken -Blob "GLD.json" -Container "scripts" -Context $Context -Permission r -StartTime $tmpStart -ExpiryTime $tmpEnd -FullURI Set-AzureRmVMDiagnosticsExtension -ResourceGroupName deb_nonprod -VMName AZINF3001 -DiagnosticsConfigurationPath $SASToken -StorageAccountName nonproddiag980

            – Deb
            Nov 22 '18 at 10:24













          • I tried in Azure runbook too and it gave me same error. Does it matter if the storage blob has more than 1 file in it?

            – Deb
            Nov 22 '18 at 10:58






          • 1





            yes that worked, wonder y it didn't work as .json. However what I did for the xml is copied the sample xml from https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/diagnostics-windows changed the resource id and storageaccount and applied it. Applied fine, but now when I try to change the settings in the portal (eg. Sample rate of processor time) it says Update failed . Also in this case for every VM I will need a separate xml, thats gona be a pain.

            – Deb
            Nov 23 '18 at 12:40

















          Thanks Joy for the response, Following is what I am getting when I try the script Set-AzureRmVMDiagnosticsExtension : Illegal characters in path. I tried something similar before by manually created the SAS and fed it to variable $diagnosticsconfig_path and it gave me same error.

          – Deb
          Nov 21 '18 at 12:22







          Thanks Joy for the response, Following is what I am getting when I try the script Set-AzureRmVMDiagnosticsExtension : Illegal characters in path. I tried something similar before by manually created the SAS and fed it to variable $diagnosticsconfig_path and it gave me same error.

          – Deb
          Nov 21 '18 at 12:22















          @Deb I test it in the runbook, it also works, see my update, could you provide your specific command? especially the -DiagnosticsConfigurationPath you used.

          – Joy Wang
          Nov 22 '18 at 5:47





          @Deb I test it in the runbook, it also works, see my update, could you provide your specific command? especially the -DiagnosticsConfigurationPath you used.

          – Joy Wang
          Nov 22 '18 at 5:47













          $SASToken = New-AzureStorageBlobSASToken -Blob "GLD.json" -Container "scripts" -Context $Context -Permission r -StartTime $tmpStart -ExpiryTime $tmpEnd -FullURI Set-AzureRmVMDiagnosticsExtension -ResourceGroupName deb_nonprod -VMName AZINF3001 -DiagnosticsConfigurationPath $SASToken -StorageAccountName nonproddiag980

          – Deb
          Nov 22 '18 at 10:24







          $SASToken = New-AzureStorageBlobSASToken -Blob "GLD.json" -Container "scripts" -Context $Context -Permission r -StartTime $tmpStart -ExpiryTime $tmpEnd -FullURI Set-AzureRmVMDiagnosticsExtension -ResourceGroupName deb_nonprod -VMName AZINF3001 -DiagnosticsConfigurationPath $SASToken -StorageAccountName nonproddiag980

          – Deb
          Nov 22 '18 at 10:24















          I tried in Azure runbook too and it gave me same error. Does it matter if the storage blob has more than 1 file in it?

          – Deb
          Nov 22 '18 at 10:58





          I tried in Azure runbook too and it gave me same error. Does it matter if the storage blob has more than 1 file in it?

          – Deb
          Nov 22 '18 at 10:58




          1




          1





          yes that worked, wonder y it didn't work as .json. However what I did for the xml is copied the sample xml from https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/diagnostics-windows changed the resource id and storageaccount and applied it. Applied fine, but now when I try to change the settings in the portal (eg. Sample rate of processor time) it says Update failed . Also in this case for every VM I will need a separate xml, thats gona be a pain.

          – Deb
          Nov 23 '18 at 12:40





          yes that worked, wonder y it didn't work as .json. However what I did for the xml is copied the sample xml from https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/diagnostics-windows changed the resource id and storageaccount and applied it. Applied fine, but now when I try to change the settings in the portal (eg. Sample rate of processor time) it says Update failed . Also in this case for every VM I will need a separate xml, thats gona be a pain.

          – Deb
          Nov 23 '18 at 12:40


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53392917%2fazure-runbook-enable-guest-level-diagnostics%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          How to fix TextFormField cause rebuild widget in Flutter

          Npm cannot find a required file even through it is in the searched directory