Boris Lipschitz
Boris Lipschitz

Reputation: 9516

Build and Deploy Azure Functions App from Build Server

I have an Azure Functions App developed in Visual Studio using C# and Microsoft.NET.Sdk.Function.

I need to build and deploy this app from our Jenkins build server. What is the recommended approach? MSBuild? MSDeploy? Azure Functions CLI? FTP? I can't use the Source Control or VSTS deployment.

Some sample scripts would be appreciated!

Upvotes: 3

Views: 3093

Answers (4)

Carlos Liu
Carlos Liu

Reputation: 2438

msbuild is OK, please refer to the link here for more info

    msbuild AzureFuncTest.sln /t:Rebuild /p:Configuration=Debug;PublishProfile=LocalDebug;DeployOnBuild=true;VisualStudioV
ersion=15.0 

Upvotes: 0

Jeremy Likness
Jeremy Likness

Reputation: 7521

You can set up continuous deployment from the configuration of the functions app. At the end of the day, you want to "publish" your applications leveraging whatever tool you like on the build server, and then have those assets deployed as the function app.

To set up the deployment, navigate to your function app.

  1. Click "Platform Features." You will see a section called "Code Deployment".
  2. Click on "Deployment Options" and you will be prompted to set up the source. Here you can choose GitHub, local git, Dropbox, etc. Let's assume you're using local git.
  3. Grab the git endpoint from the portal once you've configured it
  4. Create a git repo on your build server, locally, or wherever you want to deploy from. Set up the endpoint from (3) as a remote. The git file structure should be the root of your published function.
  5. Set up your build to push remote after publishing. Azure will detect the changes and automatically update the functions app.

This is similar for other options - for example, if you choose DropBox it will monitor the location and update once the files are changed/refreshed.

There is a full article on this capability here:

https://jlik.me/7b

Upvotes: 0

Steve Lee
Steve Lee

Reputation: 6101

That's an interesting solution! I explored the options a while back and for now just FTP and wait for the portable Functions CLI or use the CLI publish which zips up.

Upvotes: 0

Boris Lipschitz
Boris Lipschitz

Reputation: 9516

I was able to achieve the deployment in 2 steps. First, create a zip package using msbuild:

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"

Next, the package should be uploaded to azure blob storage (SAS tokens, etc) And then, I utilized MSDeploy extension of Azure AppService that downloads the package and deploys it into your Azure Functions service:

{
    "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')]"
                }
            }
        }
    ]
},

Make sure Azure Resource manager would be able to access the package!

Upvotes: 2

Related Questions