Azure逻辑应用程序:如何运行Powershell脚本或Azure CLI? [英] Azure Logic Apps: how to run Powershell script or Azure CLI?
问题描述
我正在构建Azure Logic应用程序工作区,该工作区应检查某些条件并按照Powershell运行:
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
问题是:在Azure Logic Apps中调用此类脚本的最简单方法是什么?看来Powershell没有内置的块/连接器,所以我想知道什么是可能的.或者也许通过类似的操作来运行z CLI命令可能更容易
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和cli脚本,这是
Currently, azure logic seems not support to run powershell and cli script, here is a voice in azure feedback, you could vote it.
解决方法:
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.在本地运行powershell命令以生成Web应用程序的授权令牌.
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)))
我们需要的是$base64AuthInfo
,它应该类似于JGpveXdlYmFwcDI6NnJxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzRktSdXlUcU5acUUzdFhNb05j
.
The $base64AuthInfo
is what we need, it should be like JGpveXdlYmFwcDI6NnJxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzRktSdXlUcU5acUUzdFhNb05j
.
除了您reset the publish profile
之外,令牌永远不会更改,因此您只需执行一次此步骤.
The token will never be changed except you reset the publish profile
, so you just need to do this step once.
2.在逻辑应用程序中,特定于方法,URI,标头(标头应类似于
Authorization: Basic JGpveXdlYmFwcDI6NnJxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzRktSdXlUcU5acUUzdFhNb05j
,注释使用空格分隔Basic
和令牌),例如,我在Web应用程序中启动了触发的Webjob.
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.
触发结果:
因此,您只需要按照上述步骤操作,对于您的问题,请参阅APIS:
So you just need to follow the steps above, for your issue, refer to the APIS:
- Start a continuous job
- Stop a continuous job
这篇关于Azure逻辑应用程序:如何运行Powershell脚本或Azure CLI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!