Skip to content

Commit 04710ff

Browse files
committed
Remove two files from PR
1 parent 8c2d008 commit 04710ff

File tree

2 files changed

+54
-188
lines changed

2 files changed

+54
-188
lines changed

articles/azure-functions/functions-how-to-github-actions.md

Lines changed: 46 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22
title: Use GitHub Actions to make code updates in Azure Functions
33
description: Learn how to use GitHub Actions to define a workflow to build and deploy Azure Functions projects in GitHub.
44
ms.topic: conceptual
5-
ms.date: 07/19/2024
5+
ms.date: 03/16/2024
66
ms.custom: devx-track-csharp, github-actions-azure
77
zone_pivot_groups: github-actions-deployment-options
88
---
99

1010
# Continuous delivery by using GitHub Actions
1111

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 automatically build and deploy your function code to Azure. This article supports these GitHub Actions-based deployment methods:
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.
1313

14-
| Method | Action | Tasks |
15-
| ---- | ---- | ---- |
16-
| Code-only | `Azure/functions-action` | 1. Set up the environment.<br/>2. Build the code project.<br/>3. Deploy the package to a function app in Azure. |
17-
| Container | `Azure/functions-container-action` | 1. Set up the environment.<br/>2. Build the Docker container.<br/>3. Push the image to the container registry.<br/>4. Deploy the container to Azure. |
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:
1815

19-
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.
16+
1. Set up the environment.
17+
1. Build the code project.
18+
1. Deploy the package to a function app in Azure.
19+
20+
The Azure Functions action handles the deployment to an existing function app in Azure.
2021

2122
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:
2223

@@ -32,74 +33,24 @@ If you don't want to create your YAML file by hand, select a different method at
3233

3334
+ A GitHub account. If you don't have one, sign up for [free](https://github.com/join).
3435

35-
+ Project source code in a GitHub repository.
36-
37-
+ One of these deployment targets:
38-
39-
+ A working function app hosted on Azure. This function app must have [basic authentication enabled on the `scm` endpoint](./functions-continuous-deployment.md#enable-basic-authentication-for-deployments).
40-
41-
+ An existing container registry, such as [Azure Container Registry](../container-registry/container-registry-get-started-azure-cli.md), a private container registry hosted in Azure. Examples in this article feature Azure Container Registry.
42-
::: zone pivot="method-cli,method-manual,method-template"
36+
+ A working function app hosted on Azure with source code in a GitHub repository.
37+
:::zone pivot="method-cli"
4338
+ [Azure CLI](/cli/azure/install-azure-cli), when developing locally. You can also use the Azure CLI in Azure Cloud Shell.
44-
::: zone-end
39+
:::zone-end
4540
::: zone pivot="method-manual,method-template"
4641

47-
## <a name="generate-deployment-credentials"></a>Choose deployment credentials
48-
49-
Since GitHub Actions requires credentials to be able to access Azure resources, you first need to get the credentials you need from Azure and store them securely in your repository as [GitHub secrets](https://docs.github.com/en/actions/reference/encrypted-secrets).
42+
## Generate deployment credentials
5043

51-
There are several supported authentication credentials you can use when deploying your code to Azure using GitHub Actions. This article supports these credentials:
52-
53-
| Credential | Set in... | Deployment type | Usage |
54-
| ---- | ---- | --- | --- |
55-
| Publish profile | [`Azure/functions-action`](https://github.com/marketplace/actions/azure-functions-action) | Code-only | Use the basic authentication credentials in the publish profile to connect to the `scm` deployment endpoint. |
56-
| Service principal secret |[`Azure/login`](https://github.com/Azure/login) | Code-only<br/>Containers | Using the [credentials of an Azure service principal](https://github.com/marketplace/actions/azure-login?version=v1.6.1#login-with-a-service-principal-secret) to perform identity-based authentication during deployment. |
57-
| Docker credentials | [`docker/login-action`](https://github.com/marketplace/actions/docker-login) | Container | When accessing a private Docker container registry. For an Azure Container Registry, you can also use an Azure service principal secret. |
58-
59-
You must securely store the required credentials in GitHub secrets for use by GitHub Actions during deployment.
60-
61-
## Get the service access credentals
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).
6245

6346
>[!IMPORTANT]
64-
>In this section you are working with valuable credentials that allow access to Azure resources. Make sure you always transport and store credentials securely. In GitHub, these credentials **must** only be stored as GitHub secrets.
47+
>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.
6548
66-
### [Publish profile](#tab/publish-profile)
67-
68-
Publish profile is an XML-formated object that contains basic authentication credentials used to access the `scm` deployment endpoint. These credentials are used by tools like Visual Studio and Azure Functions Core Tools to deploy code to your function app. Publish profiles require you to [enable basic authentication](./functions-continuous-deployment.md#enable-basic-authentication-for-deployments) on the `scm` management endoint.
49+
### Download your publish profile
6950

7051
[!INCLUDE [functions-download-publish-profile](../../includes/functions-download-publish-profile.md)]
7152

72-
### [Service principal secret](#tab/service-principal)
73-
74-
You can use the identity of a service principal in Azure when connecting to your app's `scm` deployment endpoint. This is also the recommended way to connect to an Azure Container Registry from your GitHub account. You use Azure role-based access control (Azure RBAC) to limit access only to the Azure resources required for publishing.
75-
76-
1. Use this [az ad sp create-for-rbac](/cli/azure/ad/sp#az-ad-sp-create-for-rbac) command to create a service principal and get its credential:
77-
78-
```azurecli
79-
az ad sp create-for-rbac --name "<APP_NAME>_deployment" --role contributor --scopes /subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.Web/sites/<APP_NAME> --sdk-auth
80-
```
81-
82-
Replace `<SUBSCRIPTION_ID>`, `<RESOURCE_GROUP>`, and `<APP_NAME>` with the names of your subscription, resource group, and function app.
83-
84-
The output from this command is a JSON object that is the credential that GitHub Actions uses to connect to your app.You need to securely retain this output until you can add as a GitHub secret.
85-
86-
1. (Optional) To deploy a containerized function app from Azure Container Registry, use this [az role assignment create](/cli/azure/role/assignment#az-role-assignment-create) command to add the `acrpull` role to the new service principal:
87-
88-
```azurecli
89-
az role assignment create --assignee <SERVICE_PRINCIPAL_ID> --scope /subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.ContainerRegistry/registries/<REGISTRY_NAME> --role acrpull
90-
```
91-
92-
Replace `<SUBSCRIPTION_ID>`, `<RESOURCE_GROUP>`, and `<REGISTRY_NAME>` with the names of your subscription, resource group, and registry.Replace `<SERVICE_PRINCIPAL_ID>` with the `clientID` from the credentials you obtained in the previous step. The role you added is scoped to your specific Azure Container Registry instance.
93-
94-
### [Docker credentials](#tab/docker-credentials)
95-
96-
You need to use registry-specific credentials when deploying a container from a private container registry. The way that you obtain this credential depends on the container registry. For more information, see [Docker Login Action](https://github.com/marketplace/actions/docker-login#usage).
97-
98-
For Azure Container Registry (ACR), you can instead use the same service principal credentials you use to deploy to Azure.
99-
100-
---
101-
102-
## Add credentials to GitHub secrets
53+
### Add the GitHub secret
10354

10455
1. In [GitHub](https://github.com/), go to your repository.
10556

@@ -109,30 +60,11 @@ For Azure Container Registry (ACR), you can instead use the same service princip
10960

11061
1. Select **New repository secret**.
11162

112-
1. Define the secret, which depends on your chosen credential:
113-
114-
### [Publish profile](#tab/publish-profile)
115-
116-
+ **Name**: `AZURE_FUNCTIONAPP_PUBLISH_PROFILE`
117-
+ **Secret**: Paste the entire XML contents of the publish profile.
118-
119-
### [Service principal secret](#tab/service-principal)
120-
121-
+ **Name**: `AZURE_CREDENTIALS`
122-
+ **Secret**: Paste the entire JSON output you obtained when you created your service principal.
123-
124-
### [Docker credentials](#tab/docker-credentials)
125-
126-
+ **Name**: `REGISTRY_USERNAME`
127-
+ **Secret**: The username of your account in the private Docker registry.
128-
+ **Name**: `REGISTRY_PASSWORD`
129-
+ **Secret**: The password for your account in the private Docker registry.
130-
131-
---
63+
1. Add a new secret with the name `AZURE_FUNCTIONAPP_PUBLISH_PROFILE` and the value set to the contents of the publishing profile file.
13264

13365
1. Select **Add secret**.
13466

135-
GitHub can now authenticate with your Azure resources during deployment.
67+
GitHub can now authenticate to your function app in Azure.
13668
::: zone-end
13769
::: zone pivot="method-manual"
13870

@@ -142,97 +74,61 @@ The best way to manually create a workflow configuration is to start from the of
14274

14375
1. Choose either **Windows** or **Linux** to make sure that you get the template for the correct operating system.
14476

145-
### [Windows](#tab/windows)
77+
# [Windows](#tab/windows)
14678

147-
Deployments to Windows use `runs-on: windows-latest`. Containerized deployments require Linux.
79+
Deployments to Windows use `runs-on: windows-latest`.
14880

149-
### [Linux](#tab/linux)
81+
# [Linux](#tab/linux)
15082

151-
Deployments to Linux use `runs-on: ubuntu-latest`. Use Linux for containerized deployments.
83+
Deployments to Linux use `runs-on: ubuntu-latest`.
15284

15385
---
15486

15587
1. Copy the language-specific template from the Azure Functions actions repository using the following link:
15688

157-
### [.NET](#tab/dotnet/windows)
89+
# [.NET](#tab/dotnet/windows)
15890

15991
<https://github.com/Azure/actions-workflow-samples/blob/master/FunctionApp/windows-dotnet-functionapp-on-azure.yml>
16092

161-
### [.NET](#tab/dotnet/linux)
93+
# [.NET](#tab/dotnet/linux)
16294

16395
<https://github.com/Azure/actions-workflow-samples/blob/master/FunctionApp/linux-dotnet-functionapp-on-azure.yml>
16496

165-
### [Java](#tab/java/windows)
97+
# [Java](#tab/java/windows)
16698

16799
<https://github.com/Azure/actions-workflow-samples/blob/master/FunctionApp/windows-java-functionapp-on-azure.yml>
168100

169-
### [Java](#tab/java/linux)
101+
# [Java](#tab/java/linux)
170102

171103
<https://github.com/Azure/actions-workflow-samples/blob/master/FunctionApp/linux-java-functionapp-on-azure.yml>
172104

173-
### [JavaScript](#tab/javascript/windows)
105+
# [JavaScript](#tab/javascript/windows)
174106

175107
<https://github.com/Azure/actions-workflow-samples/blob/master/FunctionApp/windows-node.js-functionapp-on-azure.yml>
176108

177-
### [JavaScript](#tab/javascript/linux)
109+
# [JavaScript](#tab/javascript/linux)
178110

179111
<https://github.com/Azure/actions-workflow-samples/blob/master/FunctionApp/linux-node.js-functionapp-on-azure.yml>
180112

181-
### [Python](#tab/python/windows)
113+
# [Python](#tab/python/windows)
182114

183115
Python functions aren't supported on Windows. Choose Linux instead.
184116

185-
### [Python](#tab/python/linux)
117+
# [Python](#tab/python/linux)
186118

187119
<https://github.com/Azure/actions-workflow-samples/blob/master/FunctionApp/linux-python-functionapp-on-azure.yml>
188120

189-
### [PowerShell](#tab/powershell/windows)
121+
# [PowerShell](#tab/powershell/windows)
190122

191123
<https://github.com/Azure/actions-workflow-samples/blob/master/FunctionApp/windows-powershell-functionapp-on-azure.yml>
192124

193-
### [PowerShell](#tab/powershell/linux)
125+
# [PowerShell](#tab/powershell/linux)
194126

195127
<https://github.com/Azure/actions-workflow-samples/blob/master/FunctionApp/linux-powershell-functionapp-on-azure.yml>
196-
197-
### [Container](#tab/container/windows)
198-
199-
Container deployments aren't supported on Windows. Choose Linux instead.
200128

201-
### [Container](#tab/container/linux)
202-
203-
<https://github.com/Azure/actions-workflow-samples/blob/master/FunctionApp/linux-container-functionapp-on-azure.yml>
204-
205-
Remember to do the following before you use this YAML file:
206-
207-
+ Update the values of `REGISTRY`, `NAMESPACE`, `IMAGE`, and `TAG` based on your container registry.
208-
+ Update the container respository credentials in the `docker/login-action` action. To use service principal credentials with Azure Container Registry, add an environment variable for the credentials object to your file:
209-
210-
```yml
211-
- env:
212-
creds: ${{ secrets.AZURE_CREDENTIALS }}
213-
```
214-
215-
Then replace the existing `azure/docker-Login` action with this `docker/login-action`:
216-
217-
```yml
218-
- name: Login to ACR
219-
uses: docker/login-action@v3
220-
with:
221-
registry: <registry-name>.azurecr.io
222-
username: ${{ fromJson(creds.clientId) }}
223-
password: ${{ fromJson(creds.clientSecret) }}
224-
```
225129
---
226130

227131
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#.
228-
229-
1. To connect to your app using service principal credentials instead of a publish profile, remove `publish-profile` from the `azure/functions-action` and add this `azure/login` action before `azure/functions-action`:
230-
231-
```yml
232-
- name: 'Login w/ service principal'
233-
uses: azure/login@v2
234-
with:
235-
creds: ${{ secrets.AZURE_CREDENTIALS }}
236132

237133
1. Add this new YAML file in the `/.github/workflows/` path in your repository.
238134

@@ -316,14 +212,6 @@ You can create the GitHub Actions workflow configuration file from the Azure Fun
316212
317213
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#.
318214
319-
1. To use service principal credentials instead of a publish profile, remove `publish-profile` from the `azure/functions-action` and add this `azure/login` action before `azure/functions-action`:
320-
321-
```yml
322-
- name: 'Login w/ service principal'
323-
uses: azure/login@v2
324-
with:
325-
creds: ${{ secrets.AZURE_CREDENTIALS }}
326-
327215
1. Verify that the new workflow file is being saved in `/.github/workflows/` and select **Commit changes...**.
328216
::: zone-end
329217
@@ -335,69 +223,61 @@ If for some reason, you need to update or change an existing workflow configurat
335223
336224
The following template example uses version 1 of the `functions-action` and a `publish profile` for authentication. The template depends on your chosen language and the operating system on which your function app is deployed:
337225
338-
### [Windows](#tab/windows)
226+
# [Windows](#tab/windows)
339227
340228
If your function app runs on Linux, select **Linux**.
341229
342-
### [Linux](#tab/linux)
230+
# [Linux](#tab/linux)
343231
344232
If your function app runs on Windows, select **Windows**.
345233
346234
---
347235
348-
### [.NET](#tab/dotnet/windows)
236+
# [.NET](#tab/dotnet/windows)
349237
350238
:::code language="yml" source="~/azure-actions-workflow-samples/FunctionApp/windows-dotnet-functionapp-on-azure.yml" range="1-5,13-44":::
351239
352-
### [.NET](#tab/dotnet/linux)
240+
# [.NET](#tab/dotnet/linux)
353241
354242
:::code language="yml" source="~/azure-actions-workflow-samples/FunctionApp/linux-dotnet-functionapp-on-azure.yml" range="1-5,13-44":::
355243
356-
### [Java](#tab/java/windows)
244+
# [Java](#tab/java/windows)
357245
358246
:::code language="yml" source="~/azure-actions-workflow-samples/FunctionApp/windows-java-functionapp-on-azure.yml" range="1-5,13-45":::
359247
360-
### [Java](#tab/java/linux)
248+
# [Java](#tab/java/linux)
361249
362250
:::code language="yml" source="~/azure-actions-workflow-samples/FunctionApp/linux-java-functionapp-on-azure.yml" range="1-5,13-45":::
363251
364-
### [JavaScript](#tab/javascript/windows)
252+
# [JavaScript](#tab/javascript/windows)
365253
366254
:::code language="yml" source="~/azure-actions-workflow-samples/FunctionApp/windows-node.js-functionapp-on-azure.yml" range="1-5,13-46":::
367255
368-
### [JavaScript](#tab/javascript/linux)
256+
# [JavaScript](#tab/javascript/linux)
369257
370258
:::code language="yml" source="~/azure-actions-workflow-samples/FunctionApp/linux-node.js-functionapp-on-azure.yml" range="1-5,13-46":::
371259
372-
### [Python](#tab/python/windows)
260+
# [Python](#tab/python/windows)
373261
374262
Python functions aren't supported on Windows. Choose Linux instead.
375263
376-
### [Python](#tab/python/linux)
264+
# [Python](#tab/python/linux)
377265
378266
:::code language="yml" source="~/azure-actions-workflow-samples/FunctionApp/linux-python-functionapp-on-azure.yml" range="1-5,13-47":::
379267
380-
### [PowerShell](#tab/powershell/windows)
268+
# [PowerShell](#tab/powershell/windows)
381269
382270
:::code language="yml" source="~/azure-actions-workflow-samples/FunctionApp/windows-powershell-functionapp-on-azure.yml" range="1-5,13-31":::
383271
384-
### [PowerShell](#tab/powershell/linux)
272+
# [PowerShell](#tab/powershell/linux)
385273
386274
:::code language="yml" source="~/azure-actions-workflow-samples/FunctionApp/linux-powershell-functionapp-on-azure.yml" range="1-5,13-31":::
387275
388-
### [Container](#tab/container/windows)
389-
390-
Container deployments aren't supported on Windows. Choose Linux instead.
391-
392-
### [Container](#tab/container/linux)
393-
394-
:::code language="yml" source="~/azure-actions-workflow-samples/FunctionApp/linux-container-functionapp-on-azure.yml" range="9-57":::
395-
396276
---
397277
398278
## Azure Functions action
399279
400-
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.
280+
The Azure Functions action (`Azure/azure-functions`) defines how your code is published to an existing function app in Azure, or to a specific slot in your app.
401281
402282
### Parameters
403283
@@ -407,7 +287,7 @@ The following parameters are most commonly used with this action:
407287
|---------|---------|
408288
|_**app-name**_ | (Mandatory) The name of your function app. |
409289
|_**slot-name**_ | (Optional) The name of a specific [deployment slot](functions-deployment-slots.md) you want to deploy to. The slot must already exist in your function app. When not specified, the code is deployed to the active slot. |
410-
|_**publish-profile**_ | (Optional) The name of the GitHub secret that contains your publish profile. Don't include this if you are instead using service principal credentials with `azure/login`.|
290+
|_**publish-profile**_ | (Optional) The name of the GitHub secret that contains your publish profile. |
411291
412292
The following parameters are also supported, but are used only in specific cases:
413293

0 commit comments

Comments
 (0)