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-resource-manager/bicep/deploy-github-actions.md
+30-27Lines changed: 30 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,14 @@
1
1
---
2
2
title: Deploy Bicep files by using GitHub Actions
3
3
description: In this quickstart, you learn how to deploy Bicep files by using GitHub Actions.
4
-
author: mumian
5
-
ms.author: jgao
6
4
ms.topic: conceptual
7
-
ms.date: 08/22/2022
5
+
ms.date: 01/19/2024
8
6
ms.custom: github-actions-azure, devx-track-bicep
9
7
---
10
8
11
9
# Quickstart: Deploy Bicep files by using GitHub Actions
12
10
13
-
[GitHub Actions](https://docs.github.com/en/actions) is a suite of features in GitHub to automate your software development workflows.
14
-
15
-
In this quickstart, you use the [GitHub Actions for Azure Resource Manager deployment](https://github.com/marketplace/actions/deploy-azure-resource-manager-arm-template) to automate deploying a Bicep file to Azure.
11
+
[GitHub Actions](https://docs.github.com/en/actions) is a suite of features in GitHub to automate your software development workflows. In this quickstart, you use the [GitHub Actions for Azure Resource Manager deployment](https://github.com/marketplace/actions/deploy-azure-resource-manager-arm-template) to automate deploying a Bicep file to Azure.
16
12
17
13
It provides a short introduction to GitHub actions and Bicep files. If you want more detailed steps on setting up the GitHub actions and project, see [Deploy Azure resources by using Bicep and GitHub Actions](/training/paths/bicep-github-actions).
18
14
@@ -26,38 +22,47 @@ It provides a short introduction to GitHub actions and Bicep files. If you want
26
22
27
23
Create a resource group. Later in this quickstart, you'll deploy your Bicep file to this resource group.
Your GitHub Actions run under an identity. Use the [az ad sp create-for-rbac](/cli/azure/ad/sp#az-ad-sp-create-for-rbac) command to create a [service principal](../../active-directory/develop/app-objects-and-service-principals.md#service-principal-object) for the identity.
38
-
39
-
Replace the placeholder `myApp` with the name of your application. Replace `{subscription-id}` with your subscription ID.
43
+
Your GitHub Actions run under an identity. Use the [az ad sp create-for-rbac](/cli/azure/ad/sp#az-ad-sp-create-for-rbac) command to create a [service principal](../../active-directory/develop/app-objects-and-service-principals.md#service-principal-object) for the identity. Grant the service principal the contributor role for the resource group created in the previous session so that the GitHub action with the identity can create resources in this resource group. It is recommended that you grant minimum required access.
40
44
41
45
```azurecli-interactive
42
-
az ad sp create-for-rbac --name myApp --role contributor --scopes /subscriptions/{subscription-id}/resourceGroups/exampleRG --sdk-auth
46
+
az ad sp create-for-rbac --name {app-name} --role contributor --scopes /subscriptions/{subscription-id}/resourceGroups/exampleRG --json-auth
43
47
```
44
48
45
-
> [!IMPORTANT]
46
-
> The scope in the previous example is limited to the resource group. We recommend that you grant minimum required access.
49
+
Replace the placeholder `{app-name}` with the name of your application. Replace `{subscription-id}` with your subscription ID.
47
50
48
-
The output is a JSON object with the role assignment credentials that provide access to your App Service app similar to below. Copy this JSON object for later. You'll only need the sections with the `clientId`, `clientSecret`, `subscriptionId`, and `tenantId` values.
51
+
The output is a JSON object with the role assignment credentials that provide access to your App Service app similar to below.
49
52
50
53
```output
51
54
{
52
55
"clientId": "<GUID>",
53
56
"clientSecret": "<GUID>",
54
57
"subscriptionId": "<GUID>",
55
58
"tenantId": "<GUID>",
56
-
(...)
59
+
...
57
60
}
58
61
```
59
-
# [Open ID Connect](#tab/openid)
60
62
63
+
Copy this JSON object for later. You'll only need the sections with the `clientId`, `clientSecret`, `subscriptionId`, and `tenantId` values. Make sure you don't have an extra comma at the end of the last line, for example, the `tenantId` line in the preceding example, or else it will result in an invalid JSON file. You will get an error during the deployment saying "Login failed with Error: Content is not a valid JSON object. Double check if the 'auth-type' is correct."
64
+
65
+
# [Open ID Connect](#tab/openid)
61
66
62
67
Open ID Connect is an authentication method that uses short-lived tokens. Setting up [OpenID Connect with GitHub Actions](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect) is more complex process that offers hardened security.
63
68
@@ -107,7 +112,7 @@ Open ID Connect is an authentication method that uses short-lived tokens. Settin
107
112
108
113
# [Service principal](#tab/userlevel)
109
114
110
-
Create secrets for your Azure credentials, resource group, and subscriptions.
115
+
Create secrets for your Azure credentials, resource group, and subscriptions. You will use these secrets in the [Create workflow](#create-workflow) section.
111
116
112
117
1. In [GitHub](https://github.com/), navigate to your repository.
113
118
@@ -164,23 +169,22 @@ To create a workflow, take the following steps:
164
169
# [Service principal](#tab/userlevel)
165
170
166
171
```yml
172
+
name: Deploy Bicep file
167
173
on: [push]
168
-
name: Azure ARM
169
174
jobs:
170
175
build-and-deploy:
171
176
runs-on: ubuntu-latest
172
177
steps:
173
178
174
-
# Checkout code
175
-
- uses: actions/checkout@main
179
+
- name: Checkout code
180
+
uses: actions/checkout@main
176
181
177
-
# Log into Azure
178
-
- uses: azure/login@v1
182
+
- name: Log into Azure
183
+
uses: azure/login@v1
179
184
with:
180
185
creds: ${{ secrets.AZURE_CREDENTIALS }}
181
186
182
-
# Deploy Bicep file
183
-
- name: deploy
187
+
- name: Deploy Bicep file
184
188
uses: azure/arm-deploy@v1
185
189
with:
186
190
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION }}
@@ -238,17 +242,16 @@ To create a workflow, take the following steps:
238
242
239
243
240
244
241
-
1. Select **Start commit**.
245
+
1. Select **Commit changes**.
242
246
1. Select **Commit directly to the main branch**.
243
247
1. Select **Commit new file** (or **Commit changes**).
244
248
245
249
Updating either the workflow file or Bicep file triggers the workflow. The workflow starts right after you commit the changes.
246
250
247
251
## Check workflow status
248
252
249
-
1. Select the **Actions** tab. You'll see a **Create deployStorageAccount.yml** workflow listed. It takes 1-2 minutes to run the workflow.
250
-
1. Select the workflow to open it.
251
-
1. Select **Run ARM deploy** from the menu to verify the deployment.
253
+
1. Select the **Actions** tab. You'll see a **Create deployBicepFile.yml** workflow listed. It takes 1-2 minutes to run the workflow.
254
+
1. Select the workflow to open it, and verify the `Status` is `Success`.
0 commit comments