Compartilhar via

存储队列作为Azure 事件网格事件的事件处理程序

事件处理程序是发送事件的位置。 处理程序将执行一些进一步的操作来处理事件。 自动将多个Azure服务配置为处理事件,Azure 队列存储是其中之一。

使用 队列存储 接收需要拉取的事件。 如果您有一个运行时间较长且处理时间过长的过程,可以使用队列存储。 通过将事件发送到队列存储,应用可以按自己的计划拉取和处理事件。

注释

  • 如果没有为Azure 存储帐户配置的防火墙或虚拟网络规则,则可以使用用户分配的标识和系统分配的标识将事件传送到Azure 存储帐户。
  • 如果为 Azure 存储 账户配置了防火墙或虚拟网络规则,则只有在存储账户中还启用了 允许受信任服务列表中的 Azure 服务访问存储账户 时,您才能使用系统分配的托管标识。 无论是否启用此选项,都无法使用用户分配的托管标识。

教程

有关将队列存储用作事件处理程序的示例,请参阅以下教程。

标题 说明
Quickstart:使用Azure CLI和事件网格将自定义事件路由到Azure队列存储 说明如何将自定义事件发送到队列存储。

REST 示例(对于 PUT)

作为事件处理程序的存储队列

{
	"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"
	}
}

存储队列作为事件处理器 - 通过托管身份进行传递

{
	"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"
	}
}

存储队列作为具有死信目标的事件处理程序

{
	"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"
			}
		}
	}
}

存储队列用作事件处理程序,并具有死信目标 - 托管标识

{
	"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"
				}
			}
		}
	}
}

后续步骤

如需支持的事件处理程序的列表,请参阅事件处理程序一文。