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
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-continuous-deployment.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -182,7 +182,7 @@ If you want to use a different deployment source or build provider for continuou
182
182
183
183
## Enable basic authentication for deployments
184
184
185
-
By default, your function app is created with basic authentication access to the `scm` endpoint disabled. This blocks publishing by all methods that can't use managed identities to access the `scm` endpoint. The publishing impacts of having the `scm` endpoint disabled are detailed in [Deployment without basic authentication](../app-service/configure-basic-auth-disable.md#deployment-without-basic-authentication).
185
+
In some cases, your function app is created with basic authentication access to the `scm` endpoint disabled. This blocks publishing by all methods that can't use managed identities to access the `scm` endpoint. The publishing impacts of having the `scm` endpoint disabled are detailed in [Deployment without basic authentication](../app-service/configure-basic-auth-disable.md#deployment-without-basic-authentication).
186
186
187
187
> [!IMPORTANT]
188
188
> When you use basic authenication, credentials are sent in clear text. To protect these credentials, you must only access the `scm` endpoint over an encrypted connection (HTTPS) when using basic authentication. For more information, see [Secure deployment](security-concepts.md#secure-deployment).
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. This article supports both code deployments to Azure Functions (using the `Azure/functions-action` action) and image deployments to a container registry (using `Azure/functions-container-action`).
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:
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.
15
-
16
-
### [Code deployment](#tab/code-only)
17
-
18
-
A GitHub Actions workflow for Functions performs the following tasks, regardless of language:
19
-
20
-
1. Set up the environment.
21
-
1. Build the code project.
22
-
1. Deploy the package to a function app in Azure.
23
-
24
-
The Azure Functions action handles the deployment to an existing function app in Azure.
25
-
26
-
### [Container deployment](#tab/container2)
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. |
27
18
28
-
A GitHub Actions workflow for containerized function apps performs the following tasks:
29
-
30
-
1. Set up the environment.
31
-
1. Build the Docker container.
32
-
1. Push the image to the registry.
33
-
1. Deploy the container to Azure
34
-
35
-
The Azure Functions container action handles the deployment from an existing container registry to Azure.
36
-
37
-
---
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.
38
20
39
21
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:
40
22
@@ -62,26 +44,62 @@ If you don't want to create your YAML file by hand, select a different method at
62
44
::: zone-end
63
45
::: zone pivot="method-manual,method-template"
64
46
65
-
## Generate deployment credentials
47
+
## Choose deployment credentials
66
48
67
-
Since GitHub Actions requires credentials to be able to access your function app (code deployment) your container registry (container deployment), you first need to get the credentials you need from your Azure service and store them securely as [GitHub secrets](https://docs.github.com/en/actions/reference/encrypted-secrets).
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).
68
50
69
-
### Get the service access credentals
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
70
62
71
63
>[!IMPORTANT]
72
-
>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.
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.
73
65
74
-
### [Code deployment](#tab/code-only)
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.
### [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.
79
85
80
-
The most secure way to access Azure Container Registry from your GitHub account is by using Azure role-based access control (Azure RBAC). Use these steps to create the
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. For Azure Container Registry (ACR), you can also use the service principal credential.
97
+
98
+
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).
81
99
82
100
---
83
101
84
-
###Add the GitHub secret
102
+
## Add credentials to GitHub secrets
85
103
86
104
1. In [GitHub](https://github.com/), go to your repository.
87
105
@@ -91,11 +109,30 @@ The most secure way to access Azure Container Registry from your GitHub account
91
109
92
110
1. Select **New repository secret**.
93
111
94
-
1. Add a new secret with the name `AZURE_FUNCTIONAPP_PUBLISH_PROFILE` and the value set to the contents of the publishing profile file.
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
+
---
95
132
96
133
1. Select **Add secret**.
97
134
98
-
GitHub can now authenticate to your function app in Azure.
135
+
GitHub can now authenticate with your Azure resources during deployment.
99
136
::: zone-end
100
137
::: zone pivot="method-manual"
101
138
@@ -167,14 +204,28 @@ The best way to manually create a workflow configuration is to start from the of
167
204
168
205
Remember to do the following before you use this YAML file:
169
206
170
-
+ Add `AZURE_CREDENTIALS` to your GitHub repository secrets.
171
-
+ Add `REGISTRY_USERNAME` to your GitHub repository secrets.
172
-
+ Add `REGISTRY_PASSWORD` to your GitHub repository secrets.
173
207
+ Update the values of `REGISTRY`, `NAMESPACE`, `IMAGE`, and `TAG` based on your container registry.
174
-
208
+
+ To use service principal credentials with Azure Container Registry, replace the existing `azure/docker-Login` action with this `docker/login-action`:
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#.
221
+
222
+
1. To use a service principal credential instead of a publish profile, remove `publish-profile` from the `azure/functions-action` and add this `azure/login` action before `azure/functions-action`:
223
+
224
+
```yml
225
+
- name: 'Login w/ service principal'
226
+
uses: azure/login@v2
227
+
with:
228
+
creds: ${{ secrets.AZURE_CREDENTIALS }}
178
229
179
230
1. Add this new YAML file in the `/.github/workflows/` path in your repository.
180
231
@@ -258,6 +309,14 @@ You can create the GitHub Actions workflow configuration file from the Azure Fun
258
309
259
310
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#.
260
311
312
+
1. To use a service principal credential instead of a publish profile, remove `publish-profile` from the `azure/functions-action` and add this `azure/login` action before `azure/functions-action`:
313
+
314
+
```yml
315
+
- name: 'Login w/ service principal'
316
+
uses: azure/login@v2
317
+
with:
318
+
creds: ${{ secrets.AZURE_CREDENTIALS }}
319
+
261
320
1. Verify that the new workflow file is being saved in `/.github/workflows/` and select **Commit changes...**.
262
321
::: zone-end
263
322
@@ -319,6 +378,14 @@ Python functions aren't supported on Windows. Choose Linux instead.
@@ -333,7 +400,7 @@ The following parameters are most commonly used with this action:
333
400
|---------|---------|
334
401
|_**app-name**_ | (Mandatory) The name of your function app. |
335
402
|_**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. |
336
-
|_**publish-profile**_ | (Optional) The name of the GitHub secret that contains your publish profile. |
403
+
|_**publish-profile**_ | (Optional) The name of the GitHub secret that contains your publish profile. Don't include this if you are instead using a service principal credential with `azure/login`.|
337
404
338
405
The following parameters are also supported, but are used only in specific cases:
Copy file name to clipboardExpand all lines: includes/functions-download-publish-profile.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,11 @@ ms.author: glenga
8
8
9
9
To download the publishing profile of your function app:
10
10
11
-
1. Select the function app's **Overview** page, and then select **Get publish profile**.
11
+
1. In the [Azure portal](https://portal.azure.com), locate the page for your function app, expand **Settings** > **Configuration** in the left column.
12
+
13
+
1. In the **Configuration** page, select the **General settings** tab and make sure that **SCM Basic Auth Publishing Credentials** is turned **On**. When this setting is **Off**, you can't use publish profiles, so select **On** and then **Save**.
14
+
15
+
1. Go back to the function app's **Overview** page, and then select **Get publish profile**.
0 commit comments