azure - 从构建服务器构建和部署 Azure Functions 应用程序

标签 azure jenkins continuous-integration azure-web-app-service azure-functions

我有一个使用 C# 和 Microsoft.NET.Sdk.Function 在 Visual Studio 中开发的 Azure Functions 应用程序。

我需要从我们的 Jenkins 构建服务器构建和部署此应用程序。推荐的方法是什么?微软构建?微软部署? Azure 函数 CLI? FTP? 我无法使用源代码管理或 VSTS 部署。

一些示例脚本将不胜感激!

最佳答案

我通过两步就完成了部署。首先,使用msbuild创建一个zip包:

msbuild FunctionApp.sln /p:Configuration=Release /p:DeployOnBuild=true
    /p:WebPublishMethod=Package /p:PackageAsSingleFile=true
    /p:SkipInvalidConfigurations=true
    /p:DesktopBuildPackageLocation="c:\output.zip" /p:DeployIisAppPath="Default Web Site"

接下来,应将包上传到 azure blob 存储(SAS token 等) 然后,我利用 Azure AppService 的 MSDeploy 扩展来下载包并将其部署到 Azure Functions 服务中:

{
    "apiVersion": "2015-08-01",
    "type": "Microsoft.Web/sites",
    "name": "[variables('functionAppName')]",
    "kind": "functionapp",
    "dependsOn": [
        ...
    ],
    "properties": {...},
    "resources": [
        {
            "name": "MSDeploy",
            "type": "extensions",
            "location": "[resourceGroup().location]",
            "apiVersion": "2015-08-01",
            "dependsOn": [
                "[concat('Microsoft.Web/sites/', variables('functionAppName'))]"
            ],
            "tags": {
                "displayName": "webDeploy"
            },
            "properties": {
                "packageUri": "[concat(parameters('_artifactsLocation'), '/', parameters('webDeployPackageFolder'), '/', parameters('webDeployPackageFileName'), parameters('_artifactsLocationSasToken'))]",
                "dbType": "None",
                "connectionString": "",
                "setParameters": {
                    "IIS Web Application Name": "[variables('functionAppName')]"
                }
            }
        }
    ]
},

确保 Azure 资源管理器能够访问该包!

关于azure - 从构建服务器构建和部署 Azure Functions 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46047177/

相关文章:

java - Jenkins 上抛出 SAXException

python-2.7 - 如何使用 python-jenkins 检索 jenkins 作业的最后一个控制台输出?

java - 理想的项目布局是什么样的?

azure - 在数据管道中使用 SqlReaderQuery

.net - 无法在 StorageException 处理程序中续订 Windows Azure SAS key

linux - npm install 不关心 package-lock.json

ios - Xcode 10,iOS : Test build failed even when all Tests have passed

node.js - GitLab CI/CD shell 执行器 : npm command not found

azure - Windows Azure : Can I change the instances count of worker role while the application is running on the cloud

node.js - 使用 DirectLine JS 在 NodeJs 中自定义 Azure 机器人框架