Skip to content

Commit 6020746

Browse files
authored
updating workflow to use linked function, removing key based auth (#9)
1 parent 0a2ee88 commit 6020746

File tree

6 files changed

+6
-10
lines changed

6 files changed

+6
-10
lines changed

.github/workflows/azure-static-web-apps-zealous-pond-031386310.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
3232
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
3333
app_location: 'client' # App source code path
34-
api_location: 'api' # Api source code path - optional
34+
api_location: '' # Use empty, link an existing Azure Functions app instead
3535
output_location: '' # Built app content directory - optional
3636
###### End of Repository/Build Configurations ######
3737

api/local.settings.sample.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"PUBSUB_CONNECTION_STRING": "__CHANGE_ME__",
77
"PUBSUB_HUB": "chat",
88
"STORAGE_ACCOUNT_NAME": "__CHANGE_ME__",
9-
"STORAGE_ACCOUNT_KEY": "__CHANGE_ME__"
9+
"AZURE_TENANT_ID": "__CHANGE_ME__",
10+
"AZURE_CLIENT_ID": "__CHANGE_ME__"
1011
}
1112
}

api/state.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ const { TableServiceClient, TableClient } = require('@azure/data-tables')
88
const { DefaultAzureCredential } = require('@azure/identity')
99

1010
const account = process.env.STORAGE_ACCOUNT_NAME
11-
const accountKey = process.env.STORAGE_ACCOUNT_KEY
1211
const chatsTable = 'chats'
1312
const usersTable = 'users'
1413
const partitionKey = 'chatr'
1514

16-
if (!account || !accountKey) {
17-
console.log('### 💥 Fatal! STORAGE_ACCOUNT_NAME and/or STORAGE_ACCOUNT_KEY is not set')
15+
if (!account) {
16+
console.log('### 💥 Fatal! STORAGE_ACCOUNT_NAME is not set')
1817
}
1918

2019
const credential = new DefaultAzureCredential()

deploy/deploy.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@ az deployment sub create \
2626
location="$AZURE_REGION"
2727

2828
pubSubConnStr=$(az deployment sub show --name chatr --query 'properties.outputs.pubSubConnStr.value' -o tsv)
29-
storageKey=$(az deployment sub show --name chatr --query 'properties.outputs.storageKey.value' -o tsv)
3029

3130
echo -e "\n🔨 Configuring static web app..."
3231
az staticwebapp appsettings set -n "${AZURE_PREFIX}" --setting-names \
3332
PUBSUB_CONNECTION_STRING="${pubSubConnStr}" \
3433
PUBSUB_HUB="chat" \
35-
STORAGE_ACCOUNT_KEY="${storageKey}" \
3634
STORAGE_ACCOUNT_NAME="${AZURE_PREFIX}store" > /dev/null
3735

3836
echo -e "\n✨ Deployment complete!\n🌐 The URL to accecss the app is: $(az deployment sub show --name chatr --query 'properties.outputs.appUrl.value' -o tsv)"

deploy/main.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ module pubsub 'modules/pubsub.bicep' = {
4646
}
4747
}
4848

49+
// TODO: Add principals to storage
4950
output appUrl string = 'https://${staticApp.outputs.appHostname}'
5051
output pubSubConnStr string = 'Endpoint=https://${resPrefix}.webpubsub.azure.com;AccessKey=${pubsub.outputs.key};Version=1.0;'
51-
output storageKey string = storage.outputs.key

deploy/modules/storage.bicep

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@ resource storageAcct 'Microsoft.Storage/storageAccounts@2021-02-01' = {
1010
name: 'Standard_LRS'
1111
}
1212
}
13-
14-
output key string = listKeys(storageAcct.id, storageAcct.apiVersion).keys[0].value

0 commit comments

Comments
 (0)