概要
前前回はマネージドIDを使ったblobコンテナおよびキューへのアクセスを行った。前回は接続文字列でキュートリガーを行った。
今回はマネージドIDでキュートリガーを動かす。
環境変数の設定
公式のID ベースの接続を参照に設定する。
infra/biceps/core/host/functions.bicep
param queueAndContainerStorageAccountName string
var environments = [
{
name: 'DATABASE_URL'
value: databaseUrl
}
{
name:'CONNECTION_STRING'
value: connectionString
}
- {
- name: 'BLOB_QUEUE_STORAGE_ACCOUNT_CONNECTION_STRING'
- value: 'hoge'
- }
+ {
+ name: 'BLOB_QUEUE_STORAGE_ACCOUNT__accountName'
+ value: queueAndContainerStorageAccountName
+ }
+ {
+ name: 'BLOB_QUEUE_STORAGE_ACCOUNT__queueServiceUri'
+ value: 'https://${queueAndContainerStorageAccountName}.queue.core.windows.net'
+ }
...functionEnvironments
]
apps/api/src/functions/queueTrigger.ts
import { app, InvocationContext } from '@azure/functions';
export async function storageQueueTrigger1(
queueItem: unknown,
context: InvocationContext,
): Promise<void> {
context.log('Storage queue function processed work item:', queueItem);
context.log('expirationTime =', context.triggerMetadata?.expirationTime);
}
app.storageQueue('storageQueueTrigger1', {
queueName: 'character-queue',
- connection: 'BLOB_QUEUE_STORAGE_ACCOUNT_CONNECTION_STRING',
+ connection: 'BLOB_QUEUE_STORAGE_ACCOUNT',
handler: storageQueueTrigger1,
});