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
You can use a [GitHub Actions workflow](https://docs.github.com/actions/learn-github-actions/introduction-to-github-actions#the-components-of-github-actions) to define a workflow to automatically build and deploy code to your function app in Azure Functions.
12
+
You can use a [GitHub Actions workflow](https://docs.github.com/actions/learn-github-actions/introduction-to-github-actions#the-components-of-github-actions) to define a workflow to automatically build and deploy code to your function app in Azure Functions.
13
13
14
-
A YAML file (.yml) that defines the workflow configuration is maintained in the `/.github/workflows/` path in your repository. This definition contains the actions and parameters that make up the workflow, which is specific to the development language of your functions. A GitHub Actions workflow for Functions performs the following tasks, regardless of language:
14
+
A YAML file (.yml) that defines the workflow configuration is maintained in the `/.github/workflows/` path in your repository. This definition contains the actions and parameters that make up the workflow, which is specific to the development language of your functions. A GitHub Actions workflow for Functions performs the following tasks, regardless of language:
15
15
16
16
1. Set up the environment.
17
17
1. Build the code project.
18
18
1. Deploy the package to a function app in Azure.
19
19
20
-
The Azure Functions action handles the deployment to an existing function app in Azure.
20
+
The Azure Functions action handles the deployment to an existing function app in Azure.
21
21
22
22
You can create a workflow configuration file for your deployment manually. You can also generate the file from a set of language-specific templates in one of these ways:
23
23
24
24
+ In the Azure portal
25
-
+ Using the Azure CLI
26
-
+ From your GitHub repository
25
+
+ Using the Azure CLI
26
+
+ From your GitHub repository
27
27
28
28
If you don't want to create your YAML file by hand, select a different method at the top of the article.
29
29
@@ -33,15 +33,17 @@ If you don't want to create your YAML file by hand, select a different method at
33
33
34
34
+ A GitHub account. If you don't have one, sign up for [free](https://github.com/join).
35
35
36
-
+ A working function app hosted on Azure with source code in a GitHub repository.
36
+
+ A working function app hosted on Azure with source code in a GitHub repository.
37
37
:::zone pivot="method-cli"
38
+
38
39
+[Azure CLI](/cli/azure/install-azure-cli), when developing locally. You can also use the Azure CLI in Azure Cloud Shell.
40
+
39
41
:::zone-end
40
42
::: zone pivot="method-manual,method-template"
41
43
42
44
## Generate deployment credentials
43
45
44
-
Since GitHub Actions uses your publish profile to access your function app during deployment, you first need to get your publish profile and store it securely as a [GitHub secret](https://docs.github.com/en/actions/reference/encrypted-secrets).
46
+
Since GitHub Actions uses your publish profile to access your function app during deployment, you first need to get your publish profile and store it securely as a [GitHub secret](https://docs.github.com/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets).
45
47
46
48
>[!IMPORTANT]
47
49
>The publish profile is a valuable credential that allows access to Azure resources. Make sure you always transport and store it securely. In GitHub, the publish profile must only be stored in GitHub secrets.
@@ -54,7 +56,7 @@ Since GitHub Actions uses your publish profile to access your function app durin
54
56
55
57
1. In [GitHub](https://github.com/), go to your repository.
56
58
57
-
1. Go to **Settings**.
59
+
1. Go to **Settings**.
58
60
59
61
1. Select **Secrets and variables > Actions**.
60
62
@@ -70,7 +72,7 @@ GitHub can now authenticate to your function app in Azure.
70
72
71
73
## Create the workflow from a template
72
74
73
-
The best way to manually create a workflow configuration is to start from the officially supported template.
75
+
The best way to manually create a workflow configuration is to start from the officially supported template.
74
76
75
77
1. Choose either **Windows** or **Linux** to make sure that you get the template for the correct operating system.
76
78
@@ -104,7 +106,7 @@ The best way to manually create a workflow configuration is to start from the of
1. Update the `env.AZURE_FUNCTIONAPP_NAME` parameter with the name of your function app resource in Azure. You may optionally need to update the parameter that sets the language version used by your app, such as `DOTNET_VERSION` for C#.
133
+
1. Update the `env.AZURE_FUNCTIONAPP_NAME` parameter with the name of your function app resource in Azure. You may optionally need to update the parameter that sets the language version used by your app, such as `DOTNET_VERSION` for C#.
132
134
133
-
1. Add this new YAML file in the `/.github/workflows/` path in your repository.
135
+
1. Add this new YAML file in the `/.github/workflows/` path in your repository.
134
136
135
137
::: zone-end
136
138
::: zone pivot="method-portal"
@@ -145,27 +147,28 @@ The portal automatically gets your publish profile and adds it to the GitHub sec
145
147
146
148
You can get started quickly with GitHub Actions through the Deployment tab when you create a function in Azure portal. To add a GitHub Actions workflow when you create a new function app:
147
149
148
-
1. In the [Azure portal], select **Deployment** in the **Create Function App** flow.
150
+
1. In the [Azure portal], select **Deployment** in the **Create Function App** flow.
149
151
150
152
:::image type="content" source="media/functions-how-to-github-actions/github-actions-deployment.png" alt-text="Screenshot of Deployment option in Functions menu.":::
151
153
152
-
1. Enable **Continuous Deployment** if you want each code update to trigger a code push to Azure portal.
154
+
1. Enable **Continuous Deployment** if you want each code update to trigger a code push to Azure portal.
153
155
154
-
1. Enter your GitHub organization, repository, and branch.
156
+
1. Enter your GitHub organization, repository, and branch.
155
157
156
158
:::image type="content" source="media/functions-how-to-github-actions/github-actions-github-account-details.png" alt-text="Screenshot of GitHub user account details.":::
157
159
158
-
1. Complete configuring your function app. Your GitHub repository now includes a new workflow file in `/.github/workflows/`.
160
+
1. Complete configuring your function app. Your GitHub repository now includes a new workflow file in `/.github/workflows/`.
You can use the [`az functionapp deployment github-actions add`](/cli/azure/functionapp/deployment/github-actions) command to generate a workflow configuration file from the correct template for your function app. The new YAML file is then stored in the correct location (`/.github/workflows/`) in the GitHub repository you provide, while the publish profile file for your app is added to GitHub secrets in the same repository.
171
+
You can use the [`az functionapp deployment github-actions add`](/cli/azure/functionapp/deployment/github-actions) command to generate a workflow configuration file from the correct template for your function app. The new YAML file is then stored in the correct location (`/.github/workflows/`) in the GitHub repository you provide, while the publish profile file for your app is added to GitHub secrets in the same repository.
169
172
170
173
1. Run this `az functionapp` command, replacing the values `githubUser/githubRepo`, `MyResourceGroup`, and `MyFunctionapp`:
171
174
@@ -175,7 +178,7 @@ You can use the [`az functionapp deployment github-actions add`](/cli/azure/func
175
178
176
179
This command uses an interactive method to retrieve a personal access token for your GitHub account.
177
180
178
-
1. In your terminal window, you should see something like the following message:
181
+
1. In your terminal window, you should see something like the following message:
179
182
180
183
```output
181
184
Please navigate to https://github.com/login/device and enter the user code XXXX-XXXX to activate and retrieve your GitHub personal access token.
@@ -192,23 +195,24 @@ You can use the [`az functionapp deployment github-actions add`](/cli/azure/func
192
195
Creating new workflow file: .github/workflows/master_func-app-123.yml
193
196
```
194
197
195
-
1. Go to your GitHub repository and select **Actions**. Verify that your workflow ran.
198
+
1. Go to your GitHub repository and select **Actions**. Verify that your workflow ran.
196
199
197
200
::: zone-end
198
201
::: zone pivot="method-template"
202
+
199
203
## Create the workflow configuration file
200
204
201
-
You can create the GitHub Actions workflow configuration file from the Azure Functions templates directly from your GitHub repository.
205
+
You can create the GitHub Actions workflow configuration file from the Azure Functions templates directly from your GitHub repository.
202
206
203
207
1. In [GitHub](https://github.com/), go to your repository.
204
208
205
-
1. Select **Actions** and **New workflow**.
209
+
1. Select **Actions** and **New workflow**.
206
210
207
-
1. Search for *functions*.
211
+
1. Search for *functions*.
208
212
209
213
:::image type="content" source="media/functions-how-to-github-actions/github-actions-functions-templates.png" alt-text="Screenshot of search for GitHub Actions functions templates. ":::
210
214
211
-
1. In the displayed functions app workflows authored by Microsoft Azure, find the one that matches your code language and select **Configure**.
215
+
1. In the displayed functions app workflows authored by Microsoft Azure, find the one that matches your code language and select **Configure**.
212
216
213
217
1. In the newly created YAML file, update the `env.AZURE_FUNCTIONAPP_NAME` parameter with the name of your function app resource in Azure. You may optionally need to update the parameter that sets the language version used by your app, such as `DOTNET_VERSION` for C#.
214
218
@@ -235,56 +239,56 @@ If your function app runs on Windows, select **Windows**.
The Azure Functions action (`Azure/functions-action`) defines how your code is published to an existing function app in Azure, or to a specific slot in your app.
284
+
The Azure Functions action (`Azure/functions-action`) defines how your code is published to an existing function app in Azure, or to a specific slot in your app.
281
285
282
286
### Parameters
283
287
284
288
The following parameters are required for all function app plans:
285
289
286
290
|Parameter |Explanation |
287
-
|---------|---------|
291
+
|--------- | ---------|
288
292
|_**app-name**_ | The name of your function app. |
289
293
|***package*** | This is the location in your project to be published. By default, this value is set to `.`, which means all files and folders in the GitHub repository will be deployed.|
290
294
@@ -298,22 +302,22 @@ The following parameters are required for the Flex Consumption plan:
298
302
The following parameters are specific to the Consumption, Elastic Premium, and App Service (Dedicated) plans:
299
303
300
304
|Parameter |Explanation |
301
-
|---------|---------|
305
+
|---------|---------|
302
306
|_**scm-do-build-during-deployment**_ | (Optional) Allow the Kudu site (e.g. `https://<APP_NAME>.scm.azurewebsites.net/`) to perform pre-deployment operations, such as [remote builds](functions-deployment-technologies.md#remote-build). By default, this is set to `false`. Set this to `true` when you do want to control deployment behaviors using Kudu instead of resolving dependencies in your GitHub workflow. For more information, see the [`SCM_DO_BUILD_DURING_DEPLOYMENT`](./functions-app-settings.md#scm_do_build_during_deployment) setting.|
303
307
|_**enable-oryx-build**_ | (Optional) Allow Kudu site to resolve your project dependencies with Oryx. By default, this is set to `false`. If you want to use [Oryx](https://github.com/Microsoft/Oryx) to resolve your dependencies instead of the GitHub Workflow, set both **scm-do-build-during-deployment** and **enable-oryx-build** to `true`.|
304
308
305
309
Optional parameters for all function app plans:
306
310
307
-
|Parameter |Explanation |
308
-
|---------|---------|
311
+
|Parameter | Explanation |
312
+
|--------- | ---------|
309
313
| ***slot-name*** | This is the [deployment slot](functions-deployment-slots.md) name to be deployed to. By default, this value is empty, which means the GitHub Action will deploy to your production site. When this setting points to a non-production slot, please ensure the **publish-profile** parameter contains the credentials for the slot instead of the production site. _Currently not supported in Flex Consumption_. |
310
314
|***publish-profile*** | The name of the GitHub secret that contains your publish profile.|
311
315
| _**respect-pom-xml**_ | Used only for Java functions. Whether it's required for your app's deployment artifact to be derived from the pom.xml file. When deploying Java function apps, you should set this parameter to `true` and set `package` to `.`. By default, this parameter is set to `false`, which means that the `package` parameter must point to your app's artifact location, such as `./target/azure-functions/` |
312
316
| _**respect-funcignore**_ | Whether GitHub Actions honors your .funcignore file to exclude files and folders defined in it. Set this value to `true` when your repository has a .funcignore file and you want to use it exclude paths and files, such as text editor configurations, .vscode/, or a Python virtual environment (.venv/). The default setting is `false`. |
313
317
314
318
### Considerations
315
319
316
-
Keep the following considerations in mind when using the Azure Functions action:
320
+
Keep the following considerations in mind when using the Azure Functions action:
317
321
318
322
+ When using GitHub Actions, the way that your code is deployed depends on your hosting plan, as shown in this table:
319
323
@@ -322,13 +326,13 @@ Keep the following considerations in mind when using the Azure Functions action:
\* The ability to run your apps on Linux in a Consumption plan is planned for retirement. For more information, see [Azure Functions Consumption plan hosting](consumption-plan.md).
331
+
\* The ability to run your apps on Linux in a Consumption plan is planned for retirement. For more information, see [Azure Functions Consumption plan hosting](consumption-plan.md).
328
332
329
333
+ The credentials required by GitHub to connection to Azure for deployment are stored as Secrets in your GitHub repository and accessed in the deployment as `secrets.<SECRET_NAME>`.
330
334
331
-
+ The easiest way for GitHub Actions to authenticate with Azure Functions for deployment is by using a publish profile. You can also authenticate using a service principal. To learn more, see [this GitHub Actions repository](https://github.com/Azure/functions-action).
335
+
+ The easiest way for GitHub Actions to authenticate with Azure Functions for deployment is by using a publish profile. You can also authenticate using a service principal. To learn more, see [this GitHub Actions repository](https://github.com/Azure/functions-action).
332
336
333
337
+ The actions for setting up the environment and running a build are generated from the templates, and are language specific.
0 commit comments