You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Continuously deliver function code updates by using GitHub Actions - Azure Functions
3
-
description: Learn how to set up GitHub Action that targets Azure Functions.
2
+
title: Use GitHub Actions to make code updates in Azure Functions
3
+
description: Learn how to use GitHub Actions to define a workflow to build and deploy Azure Functions projects in GitHub.
4
4
author: ahmedelnably
5
-
manager: jeconnoc
6
-
5
+
manager: gwallace
7
6
ms.service: azure-functions
8
7
ms.topic: conceptual
9
8
ms.date: 09/16/2019
@@ -12,58 +11,56 @@ ms.author: aelnably
12
11
13
12
# Continuous delivery by using GitHub Action
14
13
15
-
You can automatically deploy your function to an Azure Functions app by using [GitHub Actions](https://github.com/features/actions). As GitHub Actions still in a closed beta, you'll need to sign up [here](https://github.com/features/actions).
14
+
[GitHub Actions](https://github.com/features/actions) lets you define a workflow to automatically build and deploy your functions code to function app in Azure.
15
+
16
+
> [!IMPORTANT]
17
+
> GitHub Actions is currently in beta. You must first [sign-up to join the preview](https://github.com/features/actions) using your GitHub account.
16
18
17
-
## Create a Workflow
19
+
In GitHub Actions, a [workflow](https://help.github.com/articles/about-github-actions#workflow) is an automated process that you define in your GitHub repository. This process tells GitHub how to build and deploy your functions app project on GitHub.
18
20
19
-
For a Workflow to be executed, you need a `{whatever name you like}.yml` file under the `/.github/workflows/` path in your repo, this file contains the different steps and parameters for that workflow. For Azure Functions, we separate that file in three sections: authentication, build section, and deploy section.
21
+
A workflow is defined by a YAML (.yml) file in the `/.github/workflows/` path in your repository. This definition contains the various steps and parameters that make up the workflow.
20
22
21
-
### Authentication
23
+
For an Azure Functions workflow, the file has three sections:
22
24
23
-
To give the workflow the ability to deploy to your function app, you will need to set up two things: 1- A service principal 2- A secret under your GitHub repo called **AZURE_CREDENTIALS**
25
+
| Section | Tasks |
26
+
| ------- | ----- |
27
+
|**Authentication**| <ol><li>Define a service principal.</li><li>Create a GitHub secret.</li></ol>|
28
+
|**Build**| <ol><li>Set up the environment.</li><li>Build the function app.</li></ol> |
29
+
|**Deploy**| <ol><li>Deploy the function app.</li></ol>|
24
30
25
-
**Setting up a service principal**
31
+
## Create a service principal
26
32
27
-
You can do that by executing the following [Azure CLI](https://docs.microsoft.com/cli/azure/), this can be done from the[Azure Cloud Shell](https://shell.azure.com).
33
+
You can create a [service principal](../active-directory/develop/app-objects-and-service-principals.md#service-principal-object)by using the [az ad sp create-for-rbac](/cli/azure/ad/sp?view=azure-cli-latest#az-ad-sp-create-for-rbac) command in the [Azure CLI](/cli/azure/). You can run this command using[Azure Cloud Shell](https://shell.azure.com) in the Azure portal or by selecting the **Try it** button.
28
34
29
35
```azurecli-interactive
30
36
az ad sp create-for-rbac --name "myApp" --role contributor --scopes /subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.Web/sites/<APP_NAME> --sdk-auth
31
37
```
32
38
33
-
> [!IMPORTANT]
34
-
> It is always a good practice to grant minimum access, in this case only for the site not the whole resource group.
35
-
36
-
**Setting up a GitHub secret**
37
-
38
-
Using the output of the Azure CLI command, browse your repo webpage.
39
-
40
-
Click on Settings
39
+
In this example, replace the placeholders in the resource with your subscription ID, resource group, and function app name. The output is the role assignment credentials that provides access to your function app. Copy this JSON object, which you can use to authenticate from GitHub.
> It is always a good practice to grant minimum access. This is why the scope in the previous example is limited to the specific function app and not the entire resource group.
47
43
48
-
Add the **AZURE_CREDENTIALS** secret with the value from the output from the Azure CLI command
1. Use `AZURE_CREDENTIALS` for the **Name** and the copied command output for **Value**, then select **Add secret**.
54
51
55
-
To build you functionapp, you'll need to: 1- setup the environment, 2- build your app
52
+
GitHub can now authenticate to your function app in Azure.
56
53
57
-
**Setting up**
54
+
## Set up the environment
58
55
59
56
Setting up the environment can be done using one of the publish setup actions.
60
57
61
58
|Language | Setup Action |
62
59
|---------|---------|
63
-
|.Net| actions/setup-dotnet |
64
-
|NodeJS|actions/setup-node|
65
-
|Python|actions/setup-python|
66
-
|Java|actions/setup-java|
60
+
|**.NET**|`actions/setup-dotnet`|
61
+
|**Java**|`actions/setup-java`|
62
+
|**JavaScript**|`actions/setup-node`|
63
+
|**Python**|`actions/setup-python`|
67
64
68
65
A snippet from the yaml file for a Node JS app that uses version 10
69
66
@@ -78,7 +75,7 @@ A snippet from the yaml file for a Node JS app that uses version 10
78
75
node-version: '10.x'
79
76
```
80
77
81
-
**Build the app**
78
+
## Build the function app
82
79
83
80
This depends on the language and for languages supported by Azure Functions, this section should be the standard build steps of each language.
84
81
As an example for Node JS
@@ -98,15 +95,17 @@ A snippet from the yaml file for a Node JS app
98
95
popd
99
96
```
100
97
101
-
### Deploy
98
+
This depends on the language and for languages supported by Azure Functions, this section should be the standard build steps of each language
102
99
103
-
To deploy your code to a function app, you will need to use the `Azure/functions-action` action, there are two parameters that this action uses:
100
+
## Deploy the function app
104
101
102
+
To deploy your code to a function app, you will need to use the `Azure/functions-action` action. This action has two parameters:
105
103
106
104
|Parameter |Explanation |
107
105
|---------|---------|
108
-
|app-name | mandatory: that's the name of the azure function app |
109
-
|slot-name | optional: that's the name of the slot you want to deploy to, it should already be created under `app-name` |
106
+
|**_app-name_** | (Mandatory) The name of your function app. |
107
+
|_**slot-name**_ | (Optional) The name of the [deployment slot](functions-deployment-slots.md) you want to deploy to. The slot must already be defined in your function app. |
108
+
110
109
111
110
The following snippet show how to use version 1 of the action
112
111
@@ -118,9 +117,9 @@ The following snippet show how to use version 1 of the action
There are a number of samples available under the [Azure GitHub Actions workflow samples repo](https://github.com/Azure/actions-workflow-samples), you can use these samples a starting point for your workflow.
122
-
123
120
## Next steps
124
121
125
-
- Review the [Azure Functions overview](functions-overview.md).
126
-
- Review the [GitHub Actions page](https://github.com/features/actions).
122
+
There are a number of samples available in the [Azure GitHub Actions workflow samples repo](https://github.com/Azure/actions-workflow-samples). You can use these samples a starting point for your workflow.
123
+
124
+
> [!div class="nextstepaction"]
125
+
> [Learn more about GitHub Actions](https://help.github.com/en/articles/about-github-actions)
0 commit comments