Azure Messaging Event Subscription

This page shows how to write Terraform and Azure Resource Manager for Messaging Event Subscription and write them securely.

azurerm_eventgrid_event_subscription (Terraform)

The Event Subscription in Messaging can be configured in Terraform with the resource name azurerm_eventgrid_event_subscription. The following sections describe 7 examples of how to use the resource and its parameters.

Example Usage from GitHub

main.tf#L19
resource "azurerm_eventgrid_event_subscription" "always_succeeds_subscription" {
  name  = "alwaysSucceedsSubscription"
  scope = azurerm_eventgrid_topic.events_sample.id
  event_delivery_schema = "EventGridSchema"
  webhook_endpoint {
      url="<always-succeeds-url>"
main.tf#L1
resource "azurerm_eventgrid_event_subscription" "evnt_sub" {
  name                  = var.name
  scope                 = var.scope
  event_delivery_schema = var.event_delivery_schema
  included_event_types  = var.included_event_types

main.tf#L12
resource "azurerm_eventgrid_event_subscription" "sub" {
  name       = "event-yourname-sample"
  scope      = azurerm_eventgrid_topic.default-event-grid.id

storage_queue_endpoint {
    storage_account_id = azurerm_storage_account.default.id
main.tf#L15
resource "azurerm_eventgrid_event_subscription" "event-subscription" {
  for_each                             = var.event_subscriptions
  name                                 = format("%s%s", each.key, var.environment)
  scope                                = each.value["scope"]
  advanced_filtering_on_arrays_enabled = each.value["advanced_filtering_on_arrays_enabled"]
  event_delivery_schema                = each.value["event_delivery_schema"]
event-grid.tf#L83
resource "azurerm_eventgrid_event_subscription" "j1dev_domain_topic_subscription" {
  count = local.event_grid_domain_count
  name  = "j1dev-event-grid-domain-topic-subscription"
  scope = azurerm_eventgrid_domain_topic.j1dev[count.index].id

  storage_queue_endpoint {
main.tf#L7
resource "azurerm_eventgrid_event_subscription" "this" {
  event_delivery_schema = var.event_delivery_schema
  included_event_types  = var.included_event_types
  labels                = var.labels
  name                  = var.name
  scope                 = var.scope
main.tf#L7
resource "azurerm_eventgrid_event_subscription" "this" {
  event_delivery_schema = var.event_delivery_schema
  included_event_types  = var.included_event_types
  labels                = var.labels
  name                  = var.name
  scope                 = var.scope

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manages an EventGrid Event Subscription

Microsoft.EventGrid/topics (Azure Resource Manager)

The topics in Microsoft.EventGrid can be configured in Azure Resource Manager with the resource name Microsoft.EventGrid/topics. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

An example could not be found in GitHub.

Parameters

  • apiVersion required - string
  • identity optional
      • principalId optional - string

        The principal ID of resource identity.

      • tenantId optional - string

        The tenant ID of resource.

      • type optional - string

        The type of managed identity used. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user-assigned identities. The type 'None' will remove any identity.

      • userAssignedIdentities optional - undefined

        The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. This property is currently not used and reserved for future usage.

  • location required - string

    Location of the resource.

  • name required - string

    Name of the topic.

  • properties required
      • disableLocalAuth optional - boolean

        This boolean is used to enable or disable local auth. Default value is false. When the property is set to true, only AAD token will be used to authenticate if user is allowed to publish to the topic.

      • inboundIpRules optional array
          • action optional - string

            Action to perform based on the match or no match of the IpMask.

          • ipMask optional - string

            IP Address in CIDR notation e.g., 10.0.0.0/8.

      • inputSchema optional - string

        This determines the format that Event Grid should expect for incoming events published to the topic.

      • inputSchemaMapping optional
        • publicNetworkAccess optional - string

          This determines if traffic is allowed over public network. By default it is enabled. You can further restrict to specific IPs by configuring <seealso cref="P:Microsoft.Azure.Events.ResourceProvider.Common.Contracts.TopicProperties.InboundIpRules" />.

    • tags optional - string

      Tags of the resource.

    • type required - string

    Frequently asked questions

    What is Azure Messaging Event Subscription?

    Azure Messaging Event Subscription is a resource for Messaging of Microsoft Azure. Settings can be wrote in Terraform.

    Where can I find the example code for the Azure Messaging Event Subscription?

    For Terraform, the tomijuarez/quilmes-messaging-poc, bryannice/terraform-azure-modules and rafaelvelosoAZ/NewOne source code examples are useful. See the Terraform Example section for further details.