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/templates/deploy-github-actions.md
+22-19Lines changed: 22 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,28 +7,28 @@ ms.date: 05/01/2020
7
7
8
8
# Deploy Azure Resource Manager templates by using GitHub Actions
9
9
10
-
[GitHub Actions](https://help.github.com/en/actions) enables you to create custom software development lifecycle (SDLC) workflows directly in your GitHub repository where your Azure Resource Manager (ARM) templates are stored. A [workflow](https://help.github.com/actions/reference/workflow-syntax-for-github-actions) is defined by a YAML (.yml) file that is located inside the .github/workflows directory in your repository. Workflows must have at least one job, and jobs contain a set of steps that perform individual tasks. Steps can run commands or use an action. You can create your own actions or use actions shared by the GitHub community and customize them as needed. This article shows you how to deploy Resource Manager templates by using an Action called [Azure Resource Manager Template Deployment JS](https://github.com/marketplace/actions/azure-resource-manager-arm-template-deployment-js). You can find more actions from the [GitHub Marketplace](https://github.com/marketplace?type=actions).
10
+
[GitHub Actions](https://help.github.com/en/actions) enables you to create custom software development life-cycle workflows directly in your GitHub repository where your Azure Resource Manager (ARM) templates are stored. A [workflow](https://help.github.com/actions/reference/workflow-syntax-for-github-actions) is defined by a YAML file. Workflows have one or more jobs with each job containing a set of steps that perform individual tasks. Steps can run commands or use an action. You can create your own actions or use actions shared by the [GitHub community](https://github.com/marketplace?type=actions) and customize them as needed. This article shows how to use an action called [Azure Resource Manager Template Deployment JS](https://github.com/marketplace/actions/azure-resource-manager-arm-template-deployment-js) to deploy Resource Manager templates.
11
11
12
12
The [ARM Template Deployment JS action](https://github.com/marketplace/actions/azure-resource-manager-arm-template-deployment-js) has two dependent actions:
13
13
14
-
-[Azure Login](https://github.com/marketplace/actions/azure-login): Login with your Azure credentials
15
-
-[Checkout](https://github.com/marketplace/actions/checkout): To checks-out your repository so the workflow can access any specified Resource Manager template.
14
+
-**[Checkout](https://github.com/marketplace/actions/checkout)**: Check out your repository so the workflow can access any specified Resource Manager template.
15
+
-**[Azure Login](https://github.com/marketplace/actions/azure-login)**: Log in with your Azure credentials
16
16
17
-
A basic workflow for deploying an Resource Manager template can have three steps:
17
+
A basic workflow for deploying a Resource Manager template can have three steps:
18
18
19
19
1. Check out a template file.
20
-
2. Sign on to Azure.
21
-
3. Deploy an Resource Manager template
20
+
2. Sign in to Azure.
21
+
3. Deploy a Resource Manager template
22
22
23
23
## Prerequisites
24
24
25
25
You need a GitHub repository to store your Resource Manager templates and your workflow files. To create one, see [Creating a new repository](https://help.github.com/en/enterprise/2.14/user/articles/creating-a-new-repository).
26
26
27
27
## Configure deployment credentials
28
28
29
-
The Azure login action uses a service principal to authenticate against Azure. The principal of a CI / CD workflow typically needs the built-in contributor right in order to deploy Azure resources.
29
+
The Azure login action uses a service principal to authenticate against Azure. The principal of a CI/CD workflow typically needs the built-in contributor right in order to deploy Azure resources.
30
30
31
-
The following Azure CLI script shows how to generate an Azure Service Principal with Contributor permissions on an Azure resource group. This resource group is where the workflow will deploy the resources defined in your Resource Manager template.
31
+
The following Azure CLI script shows how to generate an Azure Service Principal with Contributor permissions on an Azure resource group. This resource group is where the workflow deploys the resources defined in your Resource Manager template.
az ad sp create-for-rbac --name $appName --role Contributor --scopes $scope --sdk-auth
40
40
```
41
41
42
-
Customize the value of $projectName and $location. The resource group name is the project name with **rg** appended.
42
+
Customize the value of **$projectName** and **$location** in the script. The resource group name is the project name with **rg** appended. You need to specify the resource group name in your workflow.
43
43
44
-
The command should output a JSON object similar to this:
44
+
The script outputs a JSON object similar to this:
45
45
46
46
```json
47
47
{
@@ -55,9 +55,7 @@ The command should output a JSON object similar to this:
55
55
56
56
Copy the JSON output and store it as a GitHub secret within your GitHub repository. See [Prerequisite](#prerequisites) if you don't have a repository yet.
57
57
58
-
From your GitHub repository:
59
-
60
-
1. Select **Settings** from the top menu.
58
+
1. From your GitHub repository, select the **Settings** tab.
61
59
1. Select **Secret** from the left menu.
62
60
1. Enter the following values:
63
61
@@ -75,13 +73,13 @@ Add an Resource Manager template to the GitHub repository. If you don't have one
You can put the file anywhere in the repository. The workflow sample assumes the template file is named **azuredeploy.json**, and it is stored in a folder called **templates** at the root of your repository.
76
+
You can put the file anywhere in the repository. The workflow sample in the next section assumes the template file is named **azuredeploy.json**, and it is stored in a folder called **templates** at the root of your repository.
79
77
80
78
## Create workflow
81
79
82
80
The workflow file must be stored in the **.github/workflow** folder at the root of your repository. The workflow file extension can be either **.yml** or **.yaml**.
83
81
84
-
You can either create a workflow file and the push or upload the file to the repository, or use the following procedure:
82
+
You can either create a workflow file and then push/upload the file to the repository, or use the following procedure:
85
83
86
84
1. From your GitHub repository, select **Actions** from the top menu.
87
85
1. Select **New workflow**.
@@ -119,27 +117,32 @@ You can either create a workflow file and the push or upload the file to the rep
119
117
templateLocation: ./templates/azuredeploy.json
120
118
```
121
119
122
-
There are three sections in the workflow:
120
+
The workflow file has three sections:
123
121
124
122
- **name**: The name of the workflow.
125
123
- **on**: The name of the GitHub events that triggers the workflow. The workflow is trigger when there is a push event on the master branch, which modifies at least one of the two files specified. The two files are the workflow file and the template file.
126
124
127
-
> ![NOTE]
125
+
> [!IMPORTANT]
128
126
> Verify the two files and their paths match yours.
129
127
- **jobs**: A workflow run is made up of one or more jobs. There is only one job called **deploy-storage-account-template**. This job has three steps:
130
128
131
129
- **Checkout source code**.
132
-
- **Login to Azure**. Verify the secret name matches to what you saved to your repository. See [Configure deployment credentials](#configure-deployment-credentials).
130
+
- **Login to Azure**.
131
+
132
+
> [!IMPORTANT]
133
+
> Verify the secret name matches to what you saved to your repository. See [Configure deployment credentials](#configure-deployment-credentials).
133
134
- **Deploy ARM template**. Replace the value of **resourceGroupName**. If you used the Azure CLI script in [Configure deployment credentials](#configure-deployment-credentials), the generated resource group name is the project name with **rg** appended. Verify the value of **templateLocation**.
134
135
135
136
1. Select **Start commit**.
136
137
1. Select **Commit new file**.
137
138
139
+
Because the workflow is configured to be triggered by either the workflow file or the template file being updated, the workflow starts right after you commit the changes.
140
+
138
141
## Check workflow status
139
142
140
143
1. Select the **Actions** tab. You shall see a **Create deployStorageAccount.yml** workflow listed. It takes 1-2 minutes to execute the workflow.
141
144
1. Select the workflow to open it.
142
-
1. Select **deploy-storage-account-template** (job name) from the left menu.
145
+
1. Select **deploy-storage-account-template** (job name) from the left menu. The job name is defined in the workflow.
143
146
1. Select **Deploy ARM Template** (step name) to expand it. You can see the REST API response.
0 commit comments