Skip to content

Commit 9124e89

Browse files
authored
removing oidc instructions
1 parent e7a20f7 commit 9124e89

File tree

1 file changed

+13
-163
lines changed

1 file changed

+13
-163
lines changed

articles/container-instances/container-instances-github-action.md

Lines changed: 13 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.author: tomcassidy
66
author: tomvcassidy
77
ms.service: container-instances
88
services: container-instances
9-
ms.date: 12/09/2022
9+
ms.date: 05/07/2024
1010
ms.custom: github-actions-azure, devx-track-azurecli
1111
---
1212

@@ -24,7 +24,7 @@ This article shows how to set up a workflow in a GitHub repo that performs the f
2424

2525
This article shows two ways to set up the workflow:
2626

27-
* [Configure GitHub workflow](#configure-github-workflow) - Create a workflow in a GitHub repo using the Deploy to Azure Container Instances action and other actions.
27+
* [Configure GitHub workflow](#configure-github-workflow) - Create a workflow in a GitHub repo using the Deploy to Azure Container Instances action and other actions.
2828
* [Use CLI extension](#use-deploy-to-azure-extension) - Use the `az container app up` command in the [Deploy to Azure](https://github.com/Azure/deploy-to-azure-cli-extension) extension in the Azure CLI. This command streamlines creation of the GitHub workflow and deployment steps.
2929

3030
> [!IMPORTANT]
@@ -50,8 +50,6 @@ This article shows two ways to set up the workflow:
5050

5151
### Create credentials for Azure authentication
5252

53-
# [Service principal](#tab/userlevel)
54-
5553
In the GitHub workflow, you need to supply Azure credentials to authenticate to the Azure CLI. The following example creates a service principal with the Contributor role scoped to the resource group for your container registry.
5654

5755
First, get the resource ID of your resource group. Substitute the name of your group in the following [az group show][az-group-show] command:
@@ -68,7 +66,7 @@ Use [az ad sp create-for-rbac][az-ad-sp-create-for-rbac] to create the service p
6866
az ad sp create-for-rbac \
6967
--scope $groupId \
7068
--role Contributor \
71-
--json-auth
69+
--sdk-auth
7270
```
7371

7472
Output is similar to:
@@ -90,68 +88,9 @@ Output is similar to:
9088

9189
Save the JSON output because it is used in a later step. Also, take note of the `clientId`, which you need to update the service principal in the next section.
9290

93-
# [OpenID Connect](#tab/openid)
94-
95-
OpenID Connect is an authentication method that uses short-lived tokens. Setting up [OpenID Connect with GitHub Actions](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect) is more complex process that offers hardened security.
96-
97-
1. If you do not have an existing application, register a [new Active Directory application and service principal that can access resources](../active-directory/develop/howto-create-service-principal-portal.md). Create the Active Directory application.
98-
99-
```azurecli-interactive
100-
az ad app create --display-name myApp
101-
```
102-
103-
This command will output JSON with an `appId` that is your `client-id`. Save the value to use as the `AZURE_CLIENT_ID` GitHub secret later.
104-
105-
You'll use the `objectId` value when creating federated credentials with Graph API and reference it as the `APPLICATION-OBJECT-ID`.
106-
107-
1. Create a service principal. Replace the `$appID` with the appId from your JSON output.
108-
109-
This command generates JSON output with a different `objectId` and will be used in the next step. The new `objectId` is the `assignee-object-id`.
110-
111-
Copy the `appOwnerTenantId` to use as a GitHub secret for `AZURE_TENANT_ID` later.
112-
113-
```azurecli-interactive
114-
az ad sp create --id $appId
115-
```
116-
117-
1. Create a new role assignment by subscription and object. By default, the role assignment will be tied to your default subscription. Replace `$subscriptionId` with your subscription ID, `$resourceGroupName` with your resource group name, and `$assigneeObjectId` with the generated `assignee-object-id`. Learn [how to manage Azure subscriptions with the Azure CLI](/cli/azure/manage-azure-subscriptions-azure-cli).
118-
119-
```azurecli-interactive
120-
az role assignment create --role contributor --subscription $subscriptionId --assignee-object-id $assigneeObjectId --scope /subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.Web/sites/ --assignee-principal-type ServicePrincipal
121-
```
122-
123-
1. Run the following command to [create a new federated identity credential](/graph/api/application-post-federatedidentitycredentials?view=graph-rest-beta&preserve-view=true) for your active directory application.
124-
125-
* Replace `APPLICATION-OBJECT-ID` with the **objectId (generated while creating app)** for your Active Directory application.
126-
* Set a value for `CREDENTIAL-NAME` to reference later.
127-
* Set the `subject`. The value of this is defined by GitHub depending on your workflow:
128-
* Jobs in your GitHub Actions environment: `repo:< Organization/Repository >:environment:< Name >`
129-
* For Jobs not tied to an environment, include the ref path for branch/tag based on the ref path used for triggering the workflow: `repo:< Organization/Repository >:ref:< ref path>`. For example, `repo:n-username/ node_express:ref:refs/heads/my-branch` or `repo:n-username/ node_express:ref:refs/tags/my-tag`.
130-
* For workflows triggered by a pull request event: `repo:< Organization/Repository >:pull_request`.
131-
132-
```azurecli-interactive
133-
az ad app federated-credential create --id <APPLICATION-OBJECT-ID> --parameters credential.json
134-
("credential.json" contains the following content)
135-
{
136-
"name": "<CREDENTIAL-NAME>",
137-
"issuer": "https://token.actions.githubusercontent.com/",
138-
"subject": "repo:organization/repository:ref:refs/heads/main",
139-
"description": "Testing",
140-
"audiences": [
141-
"api://AzureADTokenExchange"
142-
]
143-
}
144-
```
145-
146-
To learn how to create a Create an active directory application, service principal, and federated credentials in Azure portal, see [Connect GitHub and Azure](/azure/developer/github/connect-from-azure#use-the-azure-login-action-with-openid-connect).
147-
148-
---
149-
15091
### Update for registry authentication
15192

152-
# [Service principal](#tab/userlevel)
153-
154-
Update the Azure service principal credentials to allow push and pull access to your container registry. This step enables the GitHub workflow to use the service principal to [authenticate with your container registry](../container-registry/container-registry-auth-service-principal.md) and to push and pull a Docker image.
93+
Update the Azure service principal credentials to allow push and pull access to your container registry. This step enables the GitHub workflow to use the service principal to [authenticate with your container registry](../container-registry/container-registry-auth-service-principal.md) and to push and pull a Docker image.
15594

15695
Get the resource ID of your container registry. Substitute the name of your registry in the following [az acr show][az-acr-show] command:
15796

@@ -171,27 +110,8 @@ az role assignment create \
171110
--role AcrPush
172111
```
173112

174-
# [OpenID Connect](#tab/openid)
175-
176-
You need to give your application permission to access the Azure Container Registry and to create an Azure Container Instance.
177-
178-
1. In Azure portal, go to [App registrations](https://portal.azure.com/#view/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/~/RegisteredApps).
179-
1. Search for your OpenID Connect app registration and copy the **Application (client) ID**.
180-
1. Grant permissions for your app to your resource group. You'll need to set permissions at the resource group level so that you can create Azure Container instances.
181-
182-
```azurecli-interactive
183-
az role assignment create \
184-
--assignee <appID> \
185-
--role Contributor \
186-
--scope /subscriptions/<subscription-id>/resourceGroups/<resource-group>
187-
```
188-
---
189-
190-
191113
### Save credentials to GitHub repo
192114

193-
# [Service principal](#tab/userlevel)
194-
195115
1. In the GitHub UI, navigate to your forked repository and select **Security > Secrets and variables > Actions**.
196116

197117
1. Select **New repository secret** to add the following secrets:
@@ -204,33 +124,13 @@ You need to give your application permission to access the Azure Container Regis
204124
|`REGISTRY_PASSWORD` | The `clientSecret` from the JSON output from the service principal creation |
205125
| `RESOURCE_GROUP` | The name of the resource group you used to scope the service principal |
206126

207-
# [OpenID Connect](#tab/openid)
208-
209-
You need to provide your application's **Client ID**, **Tenant ID** and **Subscription ID** to the login action. These values can either be provided directly in the workflow or can be stored in GitHub secrets and referenced in your workflow. Saving the values as GitHub secrets is the more secure option.
210-
211-
1. Open your GitHub repository and go to **Settings > Security > Secrets and variables > Actions > New repository secret**.
212-
213-
1. Create secrets for `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, and `AZURE_SUBSCRIPTION_ID`. Use these values from your Active Directory application for your GitHub secrets:
214-
215-
|GitHub Secret | Active Directory Application |
216-
|---------|---------|
217-
|AZURE_CLIENT_ID | Application (client) ID |
218-
|AZURE_TENANT_ID | Directory (tenant) ID |
219-
|AZURE_SUBSCRIPTION_ID | Subscription ID |
220-
221-
1. Save each secret by selecting **Add secret**.
222-
223-
---
224-
225127
### Create workflow file
226128

227129
1. In the GitHub UI, select **Actions**.
228130
1. Select **set up a workflow yourself**.
229131
1. In **Edit new file**, paste the following YAML contents to overwrite the sample code. Accept the default filename `main.yml`, or provide a filename you choose.
230132
1. Select **Start commit**, optionally provide short and extended descriptions of your commit, and select **Commit new file**.
231133

232-
# [Service principal](#tab/userlevel)
233-
234134
```yml
235135
on: [push]
236136
name: Linux_Container_Workflow
@@ -242,16 +142,16 @@ jobs:
242142
# checkout the repo
243143
- name: 'Checkout GitHub Action'
244144
uses: actions/checkout@main
245-
145+
246146
- name: 'Login via Azure CLI'
247147
uses: azure/login@v1
248148
with:
249149
creds: ${{ secrets.AZURE_CREDENTIALS }}
250-
150+
251151
- name: 'Build and push image'
252-
uses: docker/login-action@v3
152+
uses: azure/docker-login@v1
253153
with:
254-
registry: ${{ secrets.REGISTRY_LOGIN_SERVER }}
154+
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
255155
username: ${{ secrets.REGISTRY_USERNAME }}
256156
password: ${{ secrets.REGISTRY_PASSWORD }}
257157
- run: |
@@ -271,65 +171,15 @@ jobs:
271171
location: 'west us'
272172
```
273173
274-
# [OpenID Connect](#tab/openid)
275-
276-
```yml
277-
on: [push]
278-
name: Linux_Container_Workflow_OIDC
279-
280-
permissions:
281-
id-token: write
282-
contents: read
283-
284-
on:
285-
push:
286-
branches:
287-
- main
288-
- release/*
289-
290-
jobs:
291-
build-and-deploy:
292-
runs-on: ubuntu-latest
293-
steps:
294-
- name: 'Checkout GitHub Action'
295-
uses: actions/checkout@main
296-
297-
- name: 'Login via Azure CLI'
298-
uses: azure/login@v1
299-
with:
300-
client-id: ${{ secrets.AZURE_CLIENT_ID }}
301-
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
302-
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
303-
304-
- name: Build and push image
305-
id: build-image
306-
run: |
307-
az acr build --image ${{ secrets.REGISTRY_LOGIN_SERVER }}/sampleapp:${{ github.sha }} --registry ${{ secrets.REGISTRY_LOGIN_SERVER }} --file "Dockerfile" .
308-
309-
- name: 'Deploy to Azure Container Instances'
310-
uses: 'azure/aci-deploy@v1'
311-
with:
312-
resource-group: ${{ secrets.RESOURCE_GROUP }}
313-
dns-name-label: ${{ secrets.RESOURCE_GROUP }}${{ github.run_number }}
314-
image: ${{ secrets.REGISTRY_LOGIN_SERVER }}/sampleapp:${{ github.sha }}
315-
registry-login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
316-
registry-username: ${{ secrets.REGISTRY_USERNAME }}
317-
registry-password: ${{ secrets.REGISTRY_PASSWORD }}
318-
name: aci-sampleapp
319-
location: 'west us'
320-
```
321-
322-
---
323-
324174
### Validate workflow
325175
326-
After you commit the workflow file, the workflow is triggered. To review workflow progress, navigate to **Actions** > **Workflows**.
176+
After you commit the workflow file, the workflow is triggered. To review workflow progress, navigate to **Actions** > **Workflows**.
327177
328178
![View workflow progress](./media/container-instances-github-action/github-action-progress.png)
329179
330180
See [Viewing workflow run history](https://docs.github.com/en/actions/managing-workflow-runs/viewing-workflow-run-history) for information about viewing the status and results of each step in your workflow. If the workflow doesn't complete, see [Viewing logs to diagnose failures](https://docs.github.com/en/actions/managing-workflow-runs/using-workflow-run-logs#viewing-logs-to-diagnose-failures).
331181
332-
When the workflow completes successfully, get information about the container instance named *aci-sampleapp* by running the [az container show][az-container-show] command. Substitute the name of your resource group:
182+
When the workflow completes successfully, get information about the container instance named *aci-sampleapp* by running the [az container show][az-container-show] command. Substitute the name of your resource group:
333183
334184
```azurecli-interactive
335185
az container show \
@@ -353,7 +203,7 @@ After the instance is provisioned, navigate to the container's FQDN in your brow
353203

354204
## Use Deploy to Azure extension
355205

356-
Alternatively, use the [Deploy to Azure extension](https://github.com/Azure/deploy-to-azure-cli-extension) in the Azure CLI to configure the workflow. The `az container app up` command in the extension takes input parameters from you to set up a workflow to deploy to Azure Container Instances.
206+
Alternatively, use the [Deploy to Azure extension](https://github.com/Azure/deploy-to-azure-cli-extension) in the Azure CLI to configure the workflow. The `az container app up` command in the extension takes input parameters from you to set up a workflow to deploy to Azure Container Instances.
357207

358208
The workflow created by the Azure CLI is similar to the workflow you can [create manually using GitHub](#configure-github-workflow).
359209

@@ -394,7 +244,7 @@ az container app up \
394244
* Service principal credentials for the Azure CLI
395245
* Credentials to access the Azure container registry
396246

397-
* After the command commits the workflow file to your repo, the workflow is triggered.
247+
* After the command commits the workflow file to your repo, the workflow is triggered.
398248

399249
Output is similar to:
400250

@@ -412,7 +262,7 @@ To view the workflow status and results of each step in the GitHub UI, see [View
412262

413263
### Validate workflow
414264

415-
The workflow deploys an Azure container instance with the base name of your GitHub repo, in this case, *acr-build-helloworld-node*. When the workflow completes successfully, get information about the container instance named *acr-build-helloworld-node* by running the [az container show][az-container-show] command. Substitute the name of your resource group:
265+
The workflow deploys an Azure container instance with the base name of your GitHub repo, in this case, *acr-build-helloworld-node*. When the workflow completes successfully, get information about the container instance named *acr-build-helloworld-node* by running the [az container show][az-container-show] command. Substitute the name of your resource group:
416266

417267
```azurecli-interactive
418268
az container show \

0 commit comments

Comments
 (0)