Skip to content

Commit ea1ffa7

Browse files
Merge pull request #263668 from mumian/0119-github-action
Refresh the Github action article
2 parents 91d3b7f + 76e19f3 commit ea1ffa7

File tree

1 file changed

+30
-27
lines changed

1 file changed

+30
-27
lines changed

articles/azure-resource-manager/bicep/deploy-github-actions.md

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
---
22
title: Deploy Bicep files by using GitHub Actions
33
description: In this quickstart, you learn how to deploy Bicep files by using GitHub Actions.
4-
author: mumian
5-
ms.author: jgao
64
ms.topic: conceptual
7-
ms.date: 08/22/2022
5+
ms.date: 01/19/2024
86
ms.custom: github-actions-azure, devx-track-bicep
97
---
108

119
# Quickstart: Deploy Bicep files by using GitHub Actions
1210

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.
1612

1713
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).
1814

@@ -26,38 +22,47 @@ It provides a short introduction to GitHub actions and Bicep files. If you want
2622

2723
Create a resource group. Later in this quickstart, you'll deploy your Bicep file to this resource group.
2824

25+
# [CLI](#tab/CLI)
26+
2927
```azurecli-interactive
3028
az group create -n exampleRG -l westus
3129
```
3230

31+
# [PowerShell](#tab/PowerShell)
32+
33+
```azurepowershell-interactive
34+
New-AzResourceGroup -Name exampleRG -Location westus
35+
```
36+
37+
---
38+
3339
## Generate deployment credentials
3440

3541
# [Service principal](#tab/userlevel)
3642

37-
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.
4044

4145
```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
4347
```
4448

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.
4750

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.
4952

5053
```output
5154
{
5255
"clientId": "<GUID>",
5356
"clientSecret": "<GUID>",
5457
"subscriptionId": "<GUID>",
5558
"tenantId": "<GUID>",
56-
(...)
59+
...
5760
}
5861
```
59-
# [Open ID Connect](#tab/openid)
6062

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)
6166

6267
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.
6368

@@ -107,7 +112,7 @@ Open ID Connect is an authentication method that uses short-lived tokens. Settin
107112
108113
# [Service principal](#tab/userlevel)
109114
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.
111116
112117
1. In [GitHub](https://github.com/), navigate to your repository.
113118
@@ -164,23 +169,22 @@ To create a workflow, take the following steps:
164169
# [Service principal](#tab/userlevel)
165170
166171
```yml
172+
name: Deploy Bicep file
167173
on: [push]
168-
name: Azure ARM
169174
jobs:
170175
build-and-deploy:
171176
runs-on: ubuntu-latest
172177
steps:
173178
174-
# Checkout code
175-
- uses: actions/checkout@main
179+
- name: Checkout code
180+
uses: actions/checkout@main
176181
177-
# Log into Azure
178-
- uses: azure/login@v1
182+
- name: Log into Azure
183+
uses: azure/login@v1
179184
with:
180185
creds: ${{ secrets.AZURE_CREDENTIALS }}
181186
182-
# Deploy Bicep file
183-
- name: deploy
187+
- name: Deploy Bicep file
184188
uses: azure/arm-deploy@v1
185189
with:
186190
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION }}
@@ -238,17 +242,16 @@ To create a workflow, take the following steps:
238242
239243
240244
241-
1. Select **Start commit**.
245+
1. Select **Commit changes**.
242246
1. Select **Commit directly to the main branch**.
243247
1. Select **Commit new file** (or **Commit changes**).
244248
245249
Updating either the workflow file or Bicep file triggers the workflow. The workflow starts right after you commit the changes.
246250
247251
## Check workflow status
248252
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`.
252255
253256
## Clean up resources
254257

0 commit comments

Comments
 (0)