Skip to content

Commit 0499621

Browse files
committed
Added information about Azure Login for CI/CD
1 parent 492cf9f commit 0499621

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

articles/load-testing/tutorial-cicd-github-actions.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,17 @@ The sample application's source repo includes an Apache JMeter script named *Sam
5656

5757
## Set up GitHub access permissions for Azure
5858

59-
In this section, you'll configure your GitHub repository to have permissions for accessing the Azure Load Testing resource.
59+
The GitHub Actions workflow needs to authenticate with Azure to access Azure resources. In the sample application, you use the [Azure Login](https://github.com/Azure/login) action and an Azure Active Directory service principal to authenticate with Azure. For other options to authenticate to Azure, see the [Azure and GitHub integration site](/azure/developer/github).
6060

61-
To access Azure resources, you'll create an Azure Active Directory service principal and use role-based access control to assign the necessary permissions.
61+
In this section, you'll go through the following steps:
6262

63-
1. Run the following Azure CLI command to create a service principal:
63+
- Create an Azure Active Directory service principal with the Contributor role.
64+
- Add the service principal as a GitHub secret to the sample application repository.
65+
- Assign the Load Test Contributor role to the service principal.
66+
67+
Set up your GitHub repository to have permissions to access your Azure load testing resource:
68+
69+
1. Run the following Azure CLI command to create a service principal and assign the Contributor role:
6470

6571
```azurecli
6672
az ad sp create-for-rbac --name "my-load-test-cicd" --role contributor \
@@ -108,6 +114,27 @@ To access Azure resources, you'll create an Azure Active Directory service princ
108114
--subscription "<subscription-name-or-id>"
109115
```
110116
117+
You can now use the `AZURE_CREDENTIALS` secret with the Azure Login action in your CI/CD workflow. The following code snippet describes how this for the sample application:
118+
119+
```yml
120+
jobs:
121+
build-and-deploy:
122+
# The type of runner that the job will run on
123+
runs-on: ubuntu-latest
124+
125+
# Steps represent a sequence of tasks that will be executed as part of the job
126+
steps:
127+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
128+
- name: Checkout GitHub Actions
129+
uses: actions/checkout@v2
130+
131+
- name: Login to Azure
132+
uses: azure/login@v1
133+
continue-on-error: false
134+
with:
135+
creds: ${{ secrets.AZURE_CREDENTIALS }}
136+
```
137+
111138
## Configure the GitHub Actions workflow to run a load test
112139

113140
In this section, you'll set up a GitHub Actions workflow that triggers the load test. The sample application repository contains a workflow file *SampleApp.yaml*. The workflow first deploys the sample web application to Azure App Service, and then invokes the load test. The GitHub action uses an environment variable to pass the URL of the web application to the Apache JMeter script.

0 commit comments

Comments
 (0)