使用Powershell部署到Azure功能 [英] Deploy to azure functions using powershell

查看:73
本文介绍了使用Powershell部署到Azure功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法可以使用Powershell脚本部署到Azure函数吗? CI对我们不起作用,因为我们使用章鱼部署将其部署到我们的所有生产服务中.因此,如果有一种使用Powershell脚本进行部署的方法,将是有益的.

Is there any way, I can deploy to azure functions using powershell scripts? CI will not work for us because we use octopus deploy to deploy to all of our production services. So it would be beneficial if there is a way to deploy using powershell scripts.

谢谢!

推荐答案

您可以使用 Kudu REST API .您还可以在我们的模板存储库中看到一些执行此操作的代码/示例.在代码示例中,您可以看到我们的测试脚本如何调用Kudu Rest api来将zip部署到Function App.

You can deploy functions to Azure using the Kudu REST API. You can also see some code/samples of doing this in our templates repository. In this code sample, you can see how our test script calls out to the Kudu Rest apis to deploy a zip to the Function App.

函数的文件夹结构是每个文件夹的函数.您需要将Function文件夹部署到Function App上的./site/wwwroot.如果在更新之间添加任何新的绑定,则还需要添加任何可能包含机密的应用程序设置.

The folder structure for functions is a function per folder. You need to deploy your Function folders to ./site/wwwroot on the Function App. You also need to add any app settings which might contain your secrets if you add any new bindings between updates.

PowerShell代码看起来类似于:

The PowerShell code would look something along the lines of:

    $apiUrl = $config.scmEndpoint + "/api/zip/"
    if ($destinationPath)
    {
        $apiUrl = $apiUrl + $destinationPath
    }

    $response = Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $config.authInfo)} -Method PUT -InFile $zipFilePath -ContentType "multipart/form-data"

这篇关于使用Powershell部署到Azure功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆