Skip to content

Commit 3fb296b

Browse files
committed
Update static article to emphasize OIDC and update login action
1 parent d834036 commit 3fb296b

File tree

1 file changed

+48
-47
lines changed

1 file changed

+48
-47
lines changed

articles/storage/blobs/storage-blobs-static-site-github-actions.md

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.service: azure-blob-storage
66
ms.topic: how-to
77
ms.author: shaas
88
ms.reviewer: dineshm
9-
ms.date: 01/24/2022
9+
ms.date: 02/12/2025
1010
ms.custom: devx-track-javascript, github-actions-azure, devx-track-azurecli
1111
---
1212

@@ -39,8 +39,7 @@ An Azure subscription and GitHub account.
3939

4040
## Add your workflow
4141

42-
# [Service principal](#tab/userlevel)
43-
42+
# [OpenID Connect](#tab/openid)
4443

4544
1. Go to **Actions** for your GitHub repository.
4645

@@ -51,30 +50,51 @@ An Azure subscription and GitHub account.
5150
1. Delete everything after the `on:` section of your workflow file. For example, your remaining workflow may look like this.
5251

5352
```yaml
54-
name: CI
53+
name: CI with OpenID Connect
5554

5655
on:
5756
push:
5857
branches: [ main ]
5958
```
6059
61-
1. Rename your workflow `Blob storage website CI` and add the checkout and login actions. These actions will check out your site code and authenticate with Azure using the `AZURE_CREDENTIALS` GitHub secret you created earlier.
60+
1. Add a permissions section.
61+
6262
6363
```yaml
64-
name: Blob storage website CI
64+
name: CI with OpenID Connect
6565

6666
on:
6767
push:
6868
branches: [ main ]
6969

70+
permissions:
71+
id-token: write
72+
contents: read
73+
```
74+
75+
1. Add checkout and login actions. These actions will check out your site code and authenticate with Azure using the GitHub secrets you created earlier.
76+
77+
```yaml
78+
name: CI with OpenID Connect
79+
80+
on:
81+
push:
82+
branches: [ main ]
83+
84+
permissions:
85+
id-token: write
86+
contents: read
87+
7088
jobs:
7189
build:
7290
runs-on: ubuntu-latest
7391
steps:
7492
- uses: actions/checkout@v3
75-
- uses: azure/login@v1
93+
- uses: azure/login@v2
7694
with:
77-
creds: ${{ secrets.AZURE_CREDENTIALS }}
95+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
96+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
97+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
7898
```
7999
80100
1. Use the Azure CLI action to upload your code to blob storage and to purge your CDN endpoint. For `az storage blob upload-batch`, replace the placeholder with your storage account name. The script will upload to the `$web` container. For `az cdn endpoint purge`, replace the placeholders with your CDN profile name, CDN endpoint name, and resource group. To speed up your CDN purge, you can add the `--no-wait` option to `az cdn endpoint purge`. To enhance security, you can also add the `--account-key` option with your [storage account key](../common/storage-account-keys-manage.md).
@@ -95,20 +115,26 @@ An Azure subscription and GitHub account.
95115
1. Complete your workflow by adding an action to logout of Azure. Here is the completed workflow. The file will appear in the `.github/workflows` folder of your repository.
96116

97117
```yaml
98-
name: Blob storage website CI
118+
name: CI with OpenID Connect
99119
100120
on:
101121
push:
102122
branches: [ main ]
103123
124+
permissions:
125+
id-token: write
126+
contents: read
127+
104128
jobs:
105129
build:
106130
runs-on: ubuntu-latest
107131
steps:
108132
- uses: actions/checkout@v3
109-
- uses: azure/login@v1
133+
- uses: azure/login@v2
110134
with:
111-
creds: ${{ secrets.AZURE_CREDENTIALS }}
135+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
136+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
137+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
112138
113139
- name: Upload to blob storage
114140
uses: azure/CLI@v1
@@ -128,7 +154,8 @@ An Azure subscription and GitHub account.
128154
if: always()
129155
```
130156

131-
# [OpenID Connect](#tab/openid)
157+
# [Service principal](#tab/userlevel)
158+
132159

133160
1. Go to **Actions** for your GitHub repository.
134161

@@ -139,51 +166,30 @@ An Azure subscription and GitHub account.
139166
1. Delete everything after the `on:` section of your workflow file. For example, your remaining workflow may look like this.
140167

141168
```yaml
142-
name: CI with OpenID Connect
143-
144-
on:
145-
push:
146-
branches: [ main ]
147-
```
148-
149-
1. Add a permissions section.
150-
151-
152-
```yaml
153-
name: CI with OpenID Connect
169+
name: CI
154170
155171
on:
156172
push:
157173
branches: [ main ]
158-
159-
permissions:
160-
id-token: write
161-
contents: read
162174
```
163175

164-
1. Add checkout and login actions. These actions will check out your site code and authenticate with Azure using the GitHub secrets you created earlier.
176+
1. Rename your workflow `Blob storage website CI` and add the checkout and login actions. These actions will check out your site code and authenticate with Azure using the `AZURE_CREDENTIALS` GitHub secret you created earlier.
165177

166178
```yaml
167-
name: CI with OpenID Connect
179+
name: Blob storage website CI
168180
169181
on:
170182
push:
171183
branches: [ main ]
172184
173-
permissions:
174-
id-token: write
175-
contents: read
176-
177185
jobs:
178186
build:
179187
runs-on: ubuntu-latest
180188
steps:
181189
- uses: actions/checkout@v3
182-
- uses: azure/login@v1
190+
- uses: azure/login@v2
183191
with:
184-
client-id: ${{ secrets.AZURE_CLIENT_ID }}
185-
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
186-
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
192+
creds: ${{ secrets.AZURE_CREDENTIALS }}
187193
```
188194

189195
1. Use the Azure CLI action to upload your code to blob storage and to purge your CDN endpoint. For `az storage blob upload-batch`, replace the placeholder with your storage account name. The script will upload to the `$web` container. For `az cdn endpoint purge`, replace the placeholders with your CDN profile name, CDN endpoint name, and resource group. To speed up your CDN purge, you can add the `--no-wait` option to `az cdn endpoint purge`. To enhance security, you can also add the `--account-key` option with your [storage account key](../common/storage-account-keys-manage.md).
@@ -204,26 +210,20 @@ An Azure subscription and GitHub account.
204210
1. Complete your workflow by adding an action to logout of Azure. Here is the completed workflow. The file will appear in the `.github/workflows` folder of your repository.
205211

206212
```yaml
207-
name: CI with OpenID Connect
213+
name: Blob storage website CI
208214
209215
on:
210216
push:
211217
branches: [ main ]
212218
213-
permissions:
214-
id-token: write
215-
contents: read
216-
217219
jobs:
218220
build:
219221
runs-on: ubuntu-latest
220222
steps:
221223
- uses: actions/checkout@v3
222-
- uses: azure/login@v1
224+
- uses: azure/login@v2
223225
with:
224-
client-id: ${{ secrets.AZURE_CLIENT_ID }}
225-
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
226-
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
226+
creds: ${{ secrets.AZURE_CREDENTIALS }}
227227
228228
- name: Upload to blob storage
229229
uses: azure/CLI@v1
@@ -242,6 +242,7 @@ An Azure subscription and GitHub account.
242242
az logout
243243
if: always()
244244
```
245+
245246
---
246247

247248
## Review your deployment

0 commit comments

Comments
 (0)