0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

マネージドIDでAzureFunctionsのキュートリガーを動かしたメモ

Posted at

概要

前前回はマネージド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,
});
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?