Skip to content

Commit c17aed9

Browse files
Merge pull request #2820 from juliakm/users/jukullam/authentication-gha-refresh-feb25
[DRAFT] Update GitHub Actions article for OIDC emphasis
2 parents e8cf227 + e5cb3ce commit c17aed9

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

articles/machine-learning/how-to-github-actions-machine-learning.md

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ git clone https://github.com/YOUR-USERNAME/azureml-examples
4545

4646
## Step 2: Authenticate with Azure
4747

48-
You need to first define how to authenticate with Azure. You can use a [service principal](/azure/active-directory/develop/app-objects-and-service-principals#service-principal-object) or [OpenID Connect](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect).
48+
You'll need to first define how to authenticate with Azure. The recommended, more secure option is to [sign in with OpenID Connect using a Microsoft Entra application or a user-assigned managed identity](/azure/developer/github/connect-from-azure-openid-connect). If necessary, you can also use [sign in with a service principal and secret](/azure/developer/github/connect-from-azure-secret). This approach is less secure and not recommended.
4949

5050
### Generate deployment credentials
5151

@@ -79,18 +79,17 @@ You use a `pipeline.yml` file to deploy your Azure Machine Learning pipeline. Th
7979

8080
Your workflow authenticates with Azure, sets up the Azure Machine Learning CLI, and uses the CLI to train a model in Azure Machine Learning.
8181

82-
# [Service principal](#tab/userlevel)
83-
82+
# [OpenID Connect](#tab/openid)
8483

8584
Your workflow file is made up of a trigger section and jobs:
8685
- A trigger starts the workflow in the `on` section. The workflow runs by default on a cron schedule and when a pull request is made from matching branches and paths. Learn more about [events that trigger workflows](https://docs.github.com/actions/using-workflows/events-that-trigger-workflows).
87-
- In the jobs section of the workflow, you check out code and log into Azure with your service principal secret.
86+
- In the jobs section of the workflow, you checkout code and log into Azure with the Azure login action using OpenID Connect.
87+
====
8888
- The jobs section also includes a setup action that installs and sets up the [Machine Learning CLI (v2)](how-to-configure-cli.md). Once the CLI is installed, the run job action runs your Azure Machine Learning `pipeline.yml` file to train a model with NYC taxi data.
8989

90-
9190
### Enable your workflow
9291

93-
1. In your forked repository, open `.github/workflows/cli-jobs-pipelines-nyc-taxi-pipeline.yml` and verify that your workflow looks like this.
92+
1. In your forked repository, open `.github/workflows/cli-jobs-pipelines-nyc-taxi-pipeline.yml` and verify that your workflow looks like this.
9493

9594
```yaml
9695
name: cli-jobs-pipelines-nyc-taxi-pipeline
@@ -114,9 +113,11 @@ Your workflow file is made up of a trigger section and jobs:
114113
- name: check out repo
115114
uses: actions/checkout@v2
116115
- name: azure login
117-
uses: azure/login@v1
116+
uses: azure/login@v2
118117
with:
119-
creds: ${{secrets.AZURE_CREDENTIALS}}
118+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
119+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
120+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
120121
- name: setup
121122
run: bash setup.sh
122123
working-directory: cli
@@ -125,24 +126,29 @@ Your workflow file is made up of a trigger section and jobs:
125126
run: bash -x ../../../run-job.sh pipeline.yml
126127
working-directory: cli/jobs/pipelines/nyc-taxi
127128
```
128-
129+
129130
1. Select **View runs**.
130131
1. Enable workflows by selecting **I understand my workflows, go ahead and enable them**.
131132
1. Select the **cli-jobs-pipelines-nyc-taxi-pipeline workflow** and choose to **Enable workflow**.
133+
132134
:::image type="content" source="media/how-to-github-actions-machine-learning/enable-github-actions-ml-workflow.png" alt-text="Screenshot of enable GitHub Actions workflow.":::
135+
133136
1. Select **Run workflow** and choose the option to **Run workflow** now.
137+
134138
:::image type="content" source="media/how-to-github-actions-machine-learning/github-actions-run-workflow.png" alt-text="Screenshot of run GitHub Actions workflow.":::
135139
136-
# [OpenID Connect](#tab/openid)
140+
# [Service principal](#tab/userlevel)
141+
137142
138143
Your workflow file is made up of a trigger section and jobs:
139144
- A trigger starts the workflow in the `on` section. The workflow runs by default on a cron schedule and when a pull request is made from matching branches and paths. Learn more about [events that trigger workflows](https://docs.github.com/actions/using-workflows/events-that-trigger-workflows).
140-
- In the jobs section of the workflow, you check out code and log into Azure with the Azure login action using OpenID Connect.
145+
- In the jobs section of the workflow, you checkout code and log into Azure with your service principal secret.
141146
- The jobs section also includes a setup action that installs and sets up the [Machine Learning CLI (v2)](how-to-configure-cli.md). Once the CLI is installed, the run job action runs your Azure Machine Learning `pipeline.yml` file to train a model with NYC taxi data.
142147

148+
143149
### Enable your workflow
144150

145-
1. In your forked repository, open `.github/workflows/cli-jobs-pipelines-nyc-taxi-pipeline.yml` and verify that your workflow looks like this.
151+
1. In your forked repository, open `.github/workflows/cli-jobs-pipelines-nyc-taxi-pipeline.yml` and verify that your workflow looks like this.
146152

147153
```yaml
148154
name: cli-jobs-pipelines-nyc-taxi-pipeline
@@ -166,11 +172,9 @@ Your workflow file is made up of a trigger section and jobs:
166172
- name: check out repo
167173
uses: actions/checkout@v2
168174
- name: azure login
169-
uses: azure/login@v1
175+
uses: azure/login@v2
170176
with:
171-
client-id: ${{ secrets.AZURE_CLIENT_ID }}
172-
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
173-
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
177+
creds: ${{secrets.AZURE_CREDENTIALS}}
174178
- name: setup
175179
run: bash setup.sh
176180
working-directory: cli
@@ -179,16 +183,14 @@ Your workflow file is made up of a trigger section and jobs:
179183
run: bash -x ../../../run-job.sh pipeline.yml
180184
working-directory: cli/jobs/pipelines/nyc-taxi
181185
```
182-
186+
183187
1. Select **View runs**.
184188
1. Enable workflows by selecting **I understand my workflows, go ahead and enable them**.
185189
1. Select the **cli-jobs-pipelines-nyc-taxi-pipeline workflow** and choose to **Enable workflow**.
186-
187190
:::image type="content" source="media/how-to-github-actions-machine-learning/enable-github-actions-ml-workflow.png" alt-text="Screenshot of enable GitHub Actions workflow.":::
188-
189191
1. Select **Run workflow** and choose the option to **Run workflow** now.
190-
191192
:::image type="content" source="media/how-to-github-actions-machine-learning/github-actions-run-workflow.png" alt-text="Screenshot of run GitHub Actions workflow.":::
193+
192194
---
193195

194196
## Step 6: Verify your workflow run

0 commit comments

Comments
 (0)