Skip to content

Commit e6e35e2

Browse files
committed
Updates for OIDC emphasis
1 parent b992340 commit e6e35e2

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

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

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.subservice: mlops
88
author: Blackmist
99
ms.author: larryfr
1010
ms.reviewer: jukullam
11-
ms.date: 12/06/2023
11+
ms.date: 02/07/2025
1212
ms.topic: how-to
1313
ms.custom: github-actions-azure
1414
---
@@ -45,7 +45,8 @@ git clone https://github.com/YOUR-USERNAME/azureml-examples
4545

4646
## Step 2: Authenticate with Azure
4747

48-
You'll 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.
49+
4950

5051
### Generate deployment credentials
5152

@@ -79,18 +80,16 @@ You'll use a `pipeline.yml` file to deploy your Azure Machine Learning pipeline.
7980

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

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

8585
Your workflow file is made up of a trigger section and jobs:
8686
- 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 checkout code and log into Azure with your service principal secret.
87+
- In the jobs section of the workflow, you checkout code and log into Azure with the Azure login action using OpenID Connect.
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 checkout 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)