存储队列作为 Azure 事件网格事件的事件处理程序Storage queue as an event handler for Azure Event Grid events

事件处理程序是发送事件的位置。An event handler is the place where the event is sent. 处理程序将执行一些进一步的操作来处理事件。The handler takes some further action to process the event. 多个 Azure 服务已自动配置为处理事件,Azure 队列存储就是其中之一。Several Azure services are automatically configured to handle events and Azure Queue Storage is one of them.

使用队列存储接收需拉取的事件。Use Queue Storage to receive events that need to be pulled. 如果正在运行的进程需要很长时间才能响应,可能会使用队列存储。You might use Queue storage when you have a long running process that takes too long to respond. 通过向队列存储发送事件,应用程序可以按照自己的计划拉取和处理事件。By sending events to Queue storage, the app can pull and process events on its own schedule.

教程Tutorials

有关使用队列存储作为事件处理程序的示例,请参阅以下教程。See the following tutorial for an example of using Queue storage as an event handler.

标题Title 说明Description
快速入门:使用 Azure CLI 和事件网格将自定义事件路由到 Azure 队列存储Quickstart: route custom events to Azure Queue storage with Azure CLI and Event Grid 说明如何将自定义事件发送到队列存储。Describes how to send custom events to a Queue storage.

REST 示例(适用于 PUT)REST examples (for PUT)

存储队列用作事件处理程序Storage queue as the event handler

{
    "properties": 
    {
        "destination": 
        {
            "endpointType": "StorageQueue",
            "properties": 
            {
                "resourceId": "/subscriptions/<AZURE SUBSCRIPTION ID>/resourceGroups/<RESOURCE GROUP NAME>/providers/Microsoft.Storage/storageAccounts/<STORAGE ACCOUNT NAME>",
                "queueName": "<QUEUE NAME>"
            }
        },
        "eventDeliverySchema": "EventGridSchema"
    }
}

存储队列用作事件处理程序 - 使用托管标识传送Storage queue as the event handler - delivery with managed identity

{
    "properties": 
    {
        "deliveryWithResourceIdentity": 
        {
            "identity": 
            {
                "type": "SystemAssigned"
            },
            "destination": 
            {
                "endpointType": "StorageQueue",
                "properties": 
                {
                    "resourceId": "/subscriptions/<AZURE SUBSCRIPTION ID>/resourceGroups/<RESOURCE GROUP NAME>/providers/Microsoft.Storage/storageAccounts/<STORAGE ACCOUNT NAME>",
                    "queueName": "<QUEUE NAME>"
                }
            }
        },
        "eventDeliverySchema": "EventGridSchema"
    }
}

存储队列用作死信目标Storage queue as a deadletter destination

{
    "name": "",
    "properties": 
    {
        "destination": 
        {
            "endpointType": "StorageQueue",
            "properties": 
            {
                "resourceId": "/subscriptions/<AZURE SUBSCRIPTION ID>/resourceGroups/<RESOURCE GROUP NAME>/providers/Microsoft.Storage/storageAccounts/<DESTINATION STORAGE>",
                "queueName": "queue1"
            }
        },
        "eventDeliverySchema": "EventGridSchema",
        "deadLetterDestination": 
        {
            "endpointType": "StorageBlob",
            "properties": 
            {
                "resourceId": "/subscriptions/<AZURE SUBSCRIPTION ID>/resourceGroups/<RESOURCE GROUP NAME>/providers/Microsoft.Storage/storageAccounts/<DEADLETTER STORAGE>",
                "blobContainerName": "test"
            }
        }
    }
}

存储队列用作死信目标 - 托管标识Storage queue as a deadletter destination - managed identity

{
    "properties": 
    {
        "destination": 
        {
            "endpointType": "StorageQueue",
            "properties": 
            {
                "resourceId": "/subscriptions/<AZURE SUBSCRIPTION ID>/resourceGroups/<RESOURCE GROUP NAME>/providers/Microsoft.Storage/storageAccounts/<DESTINATION STORAGE>",
                "queueName": "queue1"
            }
        },
        "eventDeliverySchema": "EventGridSchema",
        "deadLetterWithResourceIdentity": 
        {
            "identity": 
            {
                "type": "SystemAssigned"
            },
            "deadLetterDestination": 
            {
                "endpointType": "StorageBlob",
                "properties": 
                {
                    "resourceId": "/subscriptions/<AZURE SUBSCRIPTION ID>/resourceGroups/<RESOURCE GROUP NAME>/providers/Microsoft.Storage/storageAccounts/<DEADLETTER STORAGE>",
                    "blobContainerName": "test"
                }
            }
        }
    }
}

后续步骤Next steps

如需支持的事件处理程序的列表,请参阅事件处理程序一文。See the Event handlers article for a list of supported event handlers.