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
In the [previous section](../../aca/10-aca-iac-bicep/iac-bicep.md), we demonstrated how Bicep scripts can be used to automate the deployment of infrastructure components. However, creating the container registry and deploying the Bicep scripts using the Azure CLI still required manual effort. For a more efficient and streamlined process, it's preferable to use automation. Azure DevOps is a great solution for automating workflows, and in this section, we'll explain how to create a Azure DevOps pipeline for deploying the infrastructure components of our application.
8
+
9
+
The workshop repository contains a Azure Devops Pipeline yaml file that will be used to deploy the infrastructure components of our application. Follow the steps below to create a devops pipeline to deploy the infrastructure components of our application.
10
+
11
+
!!! note
12
+
The following instructions assume that you will utilize the forked Github repository both as the host for your YAML pipeline and the source code. However, it is possible to host the same assets in your Azure DevOps repository instead, if that is your preference. It is important to remember that if you choose to store your assets in your Azure DevOps repository, you will have to direct your Azure DevOps pipeline towards the Azure DevOps repository instead of the Github repository.
13
+
14
+
### Fork the GitHub repository
15
+
16
+
Start by forking the workshop repository to your GitHub account. Follow the steps below to fork the workshop:
17
+
18
+
1. Navigate to the workshop repository at [:material-github: Azure/aca-dotnet-workshop](https://github.com/Azure/aca-dotnet-workshop){target=_blank}
19
+
2. Click the **Fork** button in the top-right corner of the page.
20
+
3. Select your GitHub account to fork the repository to.
21
+
4. Wait for the repository to be forked.
22
+
23
+
### Configure a Service Connection for GitHub and Azure Subscription
24
+
25
+
Before we start with creating pipeline, we need to configure service connection for GitHub and Azure Subscription. You can do this in either existing or new project.
26
+
27
+
#### Create a Service Connection for GitHub
28
+
29
+
Provide access to the repository forked above by creating a service connection to GitHub. You create a new pipeline by first selecting a GitHub repository and then a YAML file in repository at path [.ado/infra-deploy.yml](https://raw.githubusercontent.com/Azure/aca-dotnet-workshop/main/.ado/infra-deploy.yml){target=_blank}.
30
+
31
+
The repository in which the YAML file is present is called self repository. By default, this is the repository that your pipeline builds.
32
+
33
+
There are three authentication types for granting Azure Pipelines access to your GitHub repositories while creating
34
+
a pipeline. Follow guide at [this link](https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/github?view=azure-devops&tabs=yaml#access-to-github-repositories){target=_blank}
#### Create Service Connection for Azure Subscription
41
+
42
+
Create a new service connection to your azure subscription by following the steps at [this link](https://docs.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=azure-devops&tabs=yaml#create-a-service-connection){target=_blank}.
43
+
44
+
!!! note
45
+
Update the created service connection role to have **[User Access Administrator](https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles#user-access-administrator)** role. This is required for pipeline to be able to perform role assignments in the infrastructure components deployed. To update the role of a service connection in Azure DevOps to have the User Access Administrator role, you can follow these steps:
46
+
47
+
- Navigate to the Azure portal and select the subscription where the service connection is created.
48
+
49
+
- Click on **Access control (IAM)** in the left-hand menu.
50
+
51
+
- Click on **Add role assignment**.
52
+
53
+
- For the **Assignment type** choose **Privileged administrator roles**.
54
+
55
+
- In the **Role** section choose **User Access Administrator**.
56
+
57
+
- In the **Members** section, search for the name of the service connection that you want to update and select it.
58
+
59
+
- Click **Save** to apply the changes.
60
+
61
+
### Configure Variable Group under Azure DevOps Library Section
62
+
63
+
Create a variable group named **AcaApp** under Library in your Azure Devops project. Make sure the pipeline has permissions to access the created variable group under **Pipeline permissions**.
64
+
65
+
This variable group will be used to store below details:
66
+
67
+
```bash
68
+
# AZURE_SUBSCRIPTION: Name of the service connection created for Azure Subscription
69
+
AZURE_SUBSCRIPTION=<service connection name>
70
+
71
+
# LOCATION: Azure region where resources will be deployed
72
+
LOCATION=<location>
73
+
74
+
# RESOURCE_GROUP: Name of the resource group which will be created and where the resources will be deployed
75
+
RESOURCE_GROUP=<resource group name>
76
+
77
+
# (OPTIONAL)CONTAINER_REGISTRY_NAME: Unique name of the container registry which will be created and where images will be imported
78
+
CONTAINER_REGISTRY_NAME=<container registry name>
79
+
```
80
+
81
+
!!! note
82
+
83
+
Repository variable `CONTAINER_REGISTRY_NAME` is only needed by pipeline if you intend to deploy images from a private Azure Container Registry (ACR). You may chose to skip defining this variable and the pipeline will use the [public github container registry images](https://github.com/orgs/Azure/packages?repo_name=aca-dotnet-workshop) to deploy the images.
84
+
85
+
### Trigger Azure Devops Pipeline
86
+
87
+
With these steps completed, you are now ready to trigger the Pipeline.
88
+
89
+
!!! success
90
+
91
+
Your Pipeline should be triggered and the infrastructure components of our application should be deployed successfully.
Copy file name to clipboardExpand all lines: docs/aca/10-aca-iac-bicep/ci-cd-git-action.md
+7-13Lines changed: 7 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,12 @@
1
1
2
-
# Deploy infrastructure using GitHub Actions
2
+
# Deploy Infrastructure Using GitHub Actions
3
3
4
4
!!! info "Module Duration"
5
5
30 minutes
6
6
7
-
GitHub Actions is a great way to automate your workflow. In this section, we will create a GitHub Action workflow to
8
-
deploy the infrastructure components of our application.
7
+
In the [previous section](../../aca/10-aca-iac-bicep/iac-bicep.md), we demonstrated how Bicep scripts can be used to automate the deployment of infrastructure components. However, creating the container registry and deploying the Bicep scripts using the Azure CLI still required manual effort. For a more efficient and streamlined process, it's preferable to use automation. GitHub Actions is a great solution for automating workflows, and in this section, we'll explain how to create a GitHub Action workflow for deploying the infrastructure components of our application.
9
8
10
-
The workshop repository contains a GitHub Action workflow file that will be used to deploy the infrastructure
11
-
components of our application. Follow the steps below to create a GitHub Action workflow to deploy the
12
-
infrastructure components of our application.
9
+
The workshop repository contains a GitHub Action workflow file that will be used to deploy the infrastructure components of our application. Follow the steps below to create a GitHub Action workflow to deploy the infrastructure components of our application.
13
10
14
11
### Fork the GitHub repository
15
12
@@ -109,8 +106,7 @@ locally, follow the steps below to configure the repository for OIDC authenticat
109
106
110
107
### Configure GitHub Repository Secrets
111
108
112
-
Configure secrets details in GitHub repo as described here in [create GitHub secrets](https://learn.microsoft.com/en-us/azure/developer/github/connect-from-azure?tabs=azure-cli%2Clinux#create-github-secrets).
113
-
Use below values mapped to relevant secrets in GitHub.
109
+
Configure secrets details in GitHub repo as described here in [create GitHub secrets](https://learn.microsoft.com/en-us/azure/developer/github/connect-from-azure?tabs=azure-cli%2Clinux#create-github-secrets). Use below values mapped to relevant secrets in GitHub.
114
110
115
111
```bash
116
112
# AZURE_SUBSCRIPTION_ID
@@ -123,11 +119,11 @@ echo $APP_ID
123
119
124
120
### Configure GitHub Repository Variables
125
121
126
-
Configure repository variables as shown below:
122
+
Configure repository variables in GitHub repo as described here in [create GitHub variables](https://docs.github.com/en/actions/learn-github-actions/variables). Use below values mapped to relevant variables in GitHub.
127
123
128
124
```bash
129
125
# LOCATION: Azure region where resources will be deployed
130
-
LOCATION=<location>
126
+
LOCATION=<location. e.g. eastus>
131
127
132
128
# RESOURCE_GROUP: Name of the resource group which will be created and resources will be deployed
With these steps completed, you are now ready to trigger the GitHub Actions workflow name **Build and deploy
148
-
infrastructure as code to Azure** using **workflow dispatch** to deploy the infrastructure components of our
149
-
application.
143
+
With these steps completed, you are now ready to trigger the GitHub Actions workflow named **Build and deploy infrastructure as code to Azure** using **workflow dispatch** to deploy the infrastructure components of the application.
0 commit comments