Microsoft.EventGrid eventSubscriptions template reference

Template format

To create a Microsoft.EventGrid/eventSubscriptions resource, add the following JSON to the resources section of your template.

{
  "name": "string",
  "type": "Microsoft.EventGrid/eventSubscriptions" or "<provider-namespace>/<resource-type>/providers/eventSubscriptions",
  "apiVersion": "2020-06-01",
  "properties": {
    "destination": {
      "endpointType": "string",
      "properties": {
        "queueName": "string",
        "resourceId": "string",
        "maxEventsPerBatch": "integer",
        "preferredBatchSizeInKilobytes": "integer",
        "azureActiveDirectoryApplicationIdOrUri": "string",
        "azureActiveDirectoryTenantId": "string",
        "endpointUrl": "string"
      }
    },
    "filter": {
      "subjectBeginsWith": "string",
      "subjectEndsWith": "string",
      "includedEventTypes": [
        "string"
      ],
      "isSubjectCaseSensitive": "boolean",
      "advancedFilters": [
        {
          "key": "string",
          "operatorType": "string",
          "value": "string" or "number" or "bool",
          "values": [
            "string" or "number"
          ]
        }
      ]
    },
    "labels": [
      "string"
    ],
    "expirationTimeUtc": "string",
    "eventDeliverySchema": "string",
    "retryPolicy": {
      "maxDeliveryAttempts": "integer",
      "eventTimeToLiveInMinutes": "integer"
    },
    "deadLetterDestination": {
      "endpointType": "string",
      "properties": {
        "blobContainerName": "string",
        "resourceId": "string"
      }
    }
  }
}

Property values

The following tables describe the values you need to set in the schema.

Microsoft.EventGrid/eventSubscriptions object

Name Type Required Value
name string Yes Name of the event subscription. Event subscription names must be between 3 and 64 characters in length and should use alphanumeric letters only. Use the format <resource-name>/Microsoft.EventGrid/<subscription-name> when subscribing to custom events or events for supported resource publishers.
type enum Yes Use Microsoft.EventGrid/eventSubscriptions when subscribing to resource group events. Use <provider-namespace>/<resource-type>/providers/eventSubscriptions when subscribing to custom events or events for supported resource publishers.
apiVersion enum Yes 2020-06-01
properties object Yes Properties of the event subscription. - EventSubscriptionProperties object

EventSubscriptionProperties object

Name Type Required Value
destination object No Information about the destination where events have to be delivered for the event subscription. - EventSubscriptionDestination object
filter object No Information about the filter for the event subscription. - EventSubscriptionFilter object
labels array No List of user defined labels. - string
expirationTimeUtc string No Expiration time of the event subscription.
eventDeliverySchema enum No The event delivery schema for the event subscription. - EventGridSchema, CustomInputSchema, CloudEventSchemaV1_0
retryPolicy object No The retry policy for events. This can be used to configure maximum number of delivery attempts and time to live for events. - RetryPolicy object
deadLetterDestination object No The DeadLetter destination of the event subscription. - DeadLetterDestination object

EventSubscriptionDestination object

Name Type Required Value
endpointType string Yes Type of the endpoint for the event subscription destination - EventHub, HybridConnection, StorageQueue, WebHook, ServiceBusQueue, ServiceBusTopic, or AzureFunction
properties object Yes Properties for the type of endpoint - endpointProperties object

endpointProperties object

Name Type Required Value
queueName string No For StorageQueue, the name of the Storage queue under a storage account that is the destination of an event subscription.
resourceId string No For EventHub, HybridConnection, StorageQueue, ServiceBusQueue, ServiceBusTopic, or AzureFunction, the Azure Resource Id that represents the endpoint resource of an event subscription.
azureActiveDirectoryApplicationIdOrUri string No For WebHook, the Azure Active Directory Application ID or URI to get the access token that will be included as the bearer token in delivery requests.
azureActiveDirectoryTenantId string No For WebHook, the Azure Active Directory Tenant ID to get the access token that will be included as the bearer token in delivery requests.
endpointUrl string No For WebHook, the URL that represents the endpoint of the destination of an event subscription.
maxEventsPerBatch integer No For WebHook or AzureFunction, the maximum number of events per batch.
preferredBatchSizeInKilobytes integer No For WebHook or AzureFunction, the preferred batch size in Kilobytes.

EventSubscriptionFilter object

Name Type Required Value
subjectBeginsWith string No An optional string to filter events for an event subscription based on a resource path prefix. The format of this depends on the publisher of the events. Wildcard characters are not supported in this path.
subjectEndsWith string No An optional string to filter events for an event subscription based on a resource path suffix. Wildcard characters are not supported in this path.
includedEventTypes array No A list of applicable event types that need to be part of the event subscription. If it is desired to subscribe to all default event types, set the IncludedEventTypes to null. - string
isSubjectCaseSensitive boolean No Specifies if the SubjectBeginsWith and SubjectEndsWith properties of the filter should be compared in a case sensitive manner.
advancedFilters array No An array of advanced filters that are used for filtering event subscriptions. - AdvancedFilter object

RetryPolicy object

Name Type Required Value
maxDeliveryAttempts integer No Maximum number of delivery retry attempts for events.
eventTimeToLiveInMinutes integer No Time To Live (in minutes) for events.

DeadLetterDestination object

Name Type Required Value
endpointType string Yes Type of the endpoint for the dead letter destination. - StorageBlob
properties object Yes Properties for the storage account for dead letter events. - deadletterStorageProperties object

deadletterStorageProperties object

Name Type Required Value
blobContainerName string Yes The name of the Storage blob container that is the destination of the deadletter events.
resourceId string Yes The Azure Resource ID of the storage account that is the destination of the deadletter events

AdvancedFilter object

Name Type Required Value
key string No The field/property in the event based on which you want to filter.
operatorType string Yes The type of filter to apply. - BoolEquals, NumberIn, NumberNotIn, NumberLessThan, NumberGreaterThan, NumberLessThanOrEquals, NumberGreaterThanOrEquals, StringIn, StringNotIn, StringBeginsWith, StringEndsWith, or StringContains
value string, number, or bool No For BoolEquals, NumberGreaterThan, NumberGreaterThanOrEquals, NumberLessThan, NumberLessThanOrEquals, the value to use for filtering.
values array No For NumberIn, NumberNotIn, StringBeginsWith, StringContains, StringEndsWith, StringIn, StringNotIn, the values to use for filtering.

Quickstart templates

The following quickstart templates deploy this resource type.

Template Description
Create Azure Event Grid Custom Topic and Subscription

Deploy to Azure
Creates an Azure Event Grid custom topic and a webhook subscription. Template originally authored by John Downs.
Custom Azure Event Grid Topic/Subscription with CloudEvents

Deploy to Azure
Creates a custom Azure Event Grid topic, a webhook subscription having CloudEvents schema, and a Logic App as an event handler. Template originally authored by Justin Yoo.
Create Event Grid custom topic and event hub handler.

Deploy to Azure
Creates an Azure Event Grid custom topic and event hub to handle the events.
Create Event Grid subscription for resource events

Deploy to Azure
Creates Event Grid subscription to either resource group or Azure subscription.