使用 powershell 部署到 azure 函数 [英] Deploy to azure functions using powershell

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

问题描述

有什么方法可以使用 powershell 脚本部署到 azure 函数?CI 对我们不起作用,因为我们使用 octopus deploy 来部署到我们所有的生产服务.因此,如果有一种方法可以使用 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.您还可以在我们的 模板存储库中看到一些代码/示例.在 this 代码示例中,您可以看到我们的测试脚本如何调用 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天全站免登陆