Azure Logic Apps: how to run Powershell script or Azure CLI?












0















I'm building my Azure Logic Apps worklow which is supposed to check some conditions and run following Powershell:



Stop-AzureWebsiteJob -Name MyWebsite -JobName MyWebJob
Start-AzureWebsiteJob -Name MyWebsite -JobName MyWebJob -JobType Continuous


The question is: what's the easiest way to invoke such script in Azure Logic Apps? It seems like there's no built in block/connector for Powershell so I'd like to know what are the possibilites. Or perhaps it might be easier to run az CLI command with similar operation










share|improve this question



























    0















    I'm building my Azure Logic Apps worklow which is supposed to check some conditions and run following Powershell:



    Stop-AzureWebsiteJob -Name MyWebsite -JobName MyWebJob
    Start-AzureWebsiteJob -Name MyWebsite -JobName MyWebJob -JobType Continuous


    The question is: what's the easiest way to invoke such script in Azure Logic Apps? It seems like there's no built in block/connector for Powershell so I'd like to know what are the possibilites. Or perhaps it might be easier to run az CLI command with similar operation










    share|improve this question

























      0












      0








      0








      I'm building my Azure Logic Apps worklow which is supposed to check some conditions and run following Powershell:



      Stop-AzureWebsiteJob -Name MyWebsite -JobName MyWebJob
      Start-AzureWebsiteJob -Name MyWebsite -JobName MyWebJob -JobType Continuous


      The question is: what's the easiest way to invoke such script in Azure Logic Apps? It seems like there's no built in block/connector for Powershell so I'd like to know what are the possibilites. Or perhaps it might be easier to run az CLI command with similar operation










      share|improve this question














      I'm building my Azure Logic Apps worklow which is supposed to check some conditions and run following Powershell:



      Stop-AzureWebsiteJob -Name MyWebsite -JobName MyWebJob
      Start-AzureWebsiteJob -Name MyWebsite -JobName MyWebJob -JobType Continuous


      The question is: what's the easiest way to invoke such script in Azure Logic Apps? It seems like there's no built in block/connector for Powershell so I'd like to know what are the possibilites. Or perhaps it might be easier to run az CLI command with similar operation







      azure powershell azure-logic-apps azure-cli






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 14:51









      micklmickl

      13.4k51536




      13.4k51536
























          1 Answer
          1






          active

          oldest

          votes


















          1














          Currently, azure logic seems not support to run powershell and cli script, here is a voice in azure feedback, you could vote it.



          Workaround:



          If you want to start and stop the webjob, you can call the Kudu WebJobs API in the logic app.



          You can follow the steps below.



          1.Run the powershell command locally to generate the Authorization token of your web app.



          $creds = Invoke-AzureRmResourceAction -ResourceGroupName joywebapp -ResourceType Microsoft.Web/sites/config -ResourceName joywebapp2/publishingcredentials -Action list -ApiVersion 2015-08-01 -Force
          $username = $creds.Properties.PublishingUserName
          $password = $creds.Properties.PublishingPassword
          $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))


          The $base64AuthInfo is what we need, it should be like JGpveXdlYmFwcDI6NnJxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzRktSdXlUcU5acUUzdFhNb05j.



          The token will never be changed except you reset the publish profile, so you just need to do this step once.



          2.In the logic app, specific the Method, URI, Headers(The header should be like
          Authorization: Basic JGpveXdlYmFwcDI6NnJxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzRktSdXlUcU5acUUzdFhNb05j, note use space to separate the Basic and token), for example , I start a triggered webjob in my web app.



          enter image description here



          Triggered result:



          enter image description here



          So you just need to follow the steps above, for your issue, refer to the APIS:




          1. Start a continuous job

          2. Stop a continuous job






          share|improve this answer


























          • In the meantime I've used Azure Automation and Runbooks however your answer is a great alternative and definitely needs to be accepted, thanks a lot !

            – mickl
            Nov 22 '18 at 6:10











          • @mickl Glad to know it is helpful.;-)

            – Joy Wang
            Nov 22 '18 at 6:11











          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%2f53414671%2fazure-logic-apps-how-to-run-powershell-script-or-azure-cli%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









          1














          Currently, azure logic seems not support to run powershell and cli script, here is a voice in azure feedback, you could vote it.



          Workaround:



          If you want to start and stop the webjob, you can call the Kudu WebJobs API in the logic app.



          You can follow the steps below.



          1.Run the powershell command locally to generate the Authorization token of your web app.



          $creds = Invoke-AzureRmResourceAction -ResourceGroupName joywebapp -ResourceType Microsoft.Web/sites/config -ResourceName joywebapp2/publishingcredentials -Action list -ApiVersion 2015-08-01 -Force
          $username = $creds.Properties.PublishingUserName
          $password = $creds.Properties.PublishingPassword
          $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))


          The $base64AuthInfo is what we need, it should be like JGpveXdlYmFwcDI6NnJxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzRktSdXlUcU5acUUzdFhNb05j.



          The token will never be changed except you reset the publish profile, so you just need to do this step once.



          2.In the logic app, specific the Method, URI, Headers(The header should be like
          Authorization: Basic JGpveXdlYmFwcDI6NnJxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzRktSdXlUcU5acUUzdFhNb05j, note use space to separate the Basic and token), for example , I start a triggered webjob in my web app.



          enter image description here



          Triggered result:



          enter image description here



          So you just need to follow the steps above, for your issue, refer to the APIS:




          1. Start a continuous job

          2. Stop a continuous job






          share|improve this answer


























          • In the meantime I've used Azure Automation and Runbooks however your answer is a great alternative and definitely needs to be accepted, thanks a lot !

            – mickl
            Nov 22 '18 at 6:10











          • @mickl Glad to know it is helpful.;-)

            – Joy Wang
            Nov 22 '18 at 6:11
















          1














          Currently, azure logic seems not support to run powershell and cli script, here is a voice in azure feedback, you could vote it.



          Workaround:



          If you want to start and stop the webjob, you can call the Kudu WebJobs API in the logic app.



          You can follow the steps below.



          1.Run the powershell command locally to generate the Authorization token of your web app.



          $creds = Invoke-AzureRmResourceAction -ResourceGroupName joywebapp -ResourceType Microsoft.Web/sites/config -ResourceName joywebapp2/publishingcredentials -Action list -ApiVersion 2015-08-01 -Force
          $username = $creds.Properties.PublishingUserName
          $password = $creds.Properties.PublishingPassword
          $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))


          The $base64AuthInfo is what we need, it should be like JGpveXdlYmFwcDI6NnJxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzRktSdXlUcU5acUUzdFhNb05j.



          The token will never be changed except you reset the publish profile, so you just need to do this step once.



          2.In the logic app, specific the Method, URI, Headers(The header should be like
          Authorization: Basic JGpveXdlYmFwcDI6NnJxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzRktSdXlUcU5acUUzdFhNb05j, note use space to separate the Basic and token), for example , I start a triggered webjob in my web app.



          enter image description here



          Triggered result:



          enter image description here



          So you just need to follow the steps above, for your issue, refer to the APIS:




          1. Start a continuous job

          2. Stop a continuous job






          share|improve this answer


























          • In the meantime I've used Azure Automation and Runbooks however your answer is a great alternative and definitely needs to be accepted, thanks a lot !

            – mickl
            Nov 22 '18 at 6:10











          • @mickl Glad to know it is helpful.;-)

            – Joy Wang
            Nov 22 '18 at 6:11














          1












          1








          1







          Currently, azure logic seems not support to run powershell and cli script, here is a voice in azure feedback, you could vote it.



          Workaround:



          If you want to start and stop the webjob, you can call the Kudu WebJobs API in the logic app.



          You can follow the steps below.



          1.Run the powershell command locally to generate the Authorization token of your web app.



          $creds = Invoke-AzureRmResourceAction -ResourceGroupName joywebapp -ResourceType Microsoft.Web/sites/config -ResourceName joywebapp2/publishingcredentials -Action list -ApiVersion 2015-08-01 -Force
          $username = $creds.Properties.PublishingUserName
          $password = $creds.Properties.PublishingPassword
          $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))


          The $base64AuthInfo is what we need, it should be like JGpveXdlYmFwcDI6NnJxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzRktSdXlUcU5acUUzdFhNb05j.



          The token will never be changed except you reset the publish profile, so you just need to do this step once.



          2.In the logic app, specific the Method, URI, Headers(The header should be like
          Authorization: Basic JGpveXdlYmFwcDI6NnJxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzRktSdXlUcU5acUUzdFhNb05j, note use space to separate the Basic and token), for example , I start a triggered webjob in my web app.



          enter image description here



          Triggered result:



          enter image description here



          So you just need to follow the steps above, for your issue, refer to the APIS:




          1. Start a continuous job

          2. Stop a continuous job






          share|improve this answer















          Currently, azure logic seems not support to run powershell and cli script, here is a voice in azure feedback, you could vote it.



          Workaround:



          If you want to start and stop the webjob, you can call the Kudu WebJobs API in the logic app.



          You can follow the steps below.



          1.Run the powershell command locally to generate the Authorization token of your web app.



          $creds = Invoke-AzureRmResourceAction -ResourceGroupName joywebapp -ResourceType Microsoft.Web/sites/config -ResourceName joywebapp2/publishingcredentials -Action list -ApiVersion 2015-08-01 -Force
          $username = $creds.Properties.PublishingUserName
          $password = $creds.Properties.PublishingPassword
          $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))


          The $base64AuthInfo is what we need, it should be like JGpveXdlYmFwcDI6NnJxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzRktSdXlUcU5acUUzdFhNb05j.



          The token will never be changed except you reset the publish profile, so you just need to do this step once.



          2.In the logic app, specific the Method, URI, Headers(The header should be like
          Authorization: Basic JGpveXdlYmFwcDI6NnJxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzRktSdXlUcU5acUUzdFhNb05j, note use space to separate the Basic and token), for example , I start a triggered webjob in my web app.



          enter image description here



          Triggered result:



          enter image description here



          So you just need to follow the steps above, for your issue, refer to the APIS:




          1. Start a continuous job

          2. Stop a continuous job







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 22 '18 at 3:13

























          answered Nov 22 '18 at 3:04









          Joy WangJoy Wang

          7,2982213




          7,2982213













          • In the meantime I've used Azure Automation and Runbooks however your answer is a great alternative and definitely needs to be accepted, thanks a lot !

            – mickl
            Nov 22 '18 at 6:10











          • @mickl Glad to know it is helpful.;-)

            – Joy Wang
            Nov 22 '18 at 6:11



















          • In the meantime I've used Azure Automation and Runbooks however your answer is a great alternative and definitely needs to be accepted, thanks a lot !

            – mickl
            Nov 22 '18 at 6:10











          • @mickl Glad to know it is helpful.;-)

            – Joy Wang
            Nov 22 '18 at 6:11

















          In the meantime I've used Azure Automation and Runbooks however your answer is a great alternative and definitely needs to be accepted, thanks a lot !

          – mickl
          Nov 22 '18 at 6:10





          In the meantime I've used Azure Automation and Runbooks however your answer is a great alternative and definitely needs to be accepted, thanks a lot !

          – mickl
          Nov 22 '18 at 6:10













          @mickl Glad to know it is helpful.;-)

          – Joy Wang
          Nov 22 '18 at 6:11





          @mickl Glad to know it is helpful.;-)

          – Joy Wang
          Nov 22 '18 at 6:11




















          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%2f53414671%2fazure-logic-apps-how-to-run-powershell-script-or-azure-cli%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

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

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