Event Subscriptions - Create

Create an event subscription Asynchronously creates a new event subscription to the specified scope. Existing event subscriptions cannot be updated with this API and should instead use the Update event subscription API.

PUT https://management.azure.com/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}?api-version=2017-06-15-preview

URI Parameters

Name In Required Type Description
scope
path True
  • string

The scope of the resource to which the event subscription needs to be created. The scope can be a subscription, or a resource group, or a top level resource belonging to a resource provider namespace, or an EventGrid topic. For example, use '/subscriptions/{subscriptionId}/' for a subscription, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' for a resource, and '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' for an EventGrid topic.

eventSubscriptionName
path True
  • string

Name of the event subscription to be created. Event subscription names must be between 3 and 64 characters in length and use alphanumeric letters only.

api-version
query True
  • string

Version of the API to be used with the client request.

Request Body

Name Required Type Description
properties.destination

Information about the destination where events have to be delivered for the event subscription.

properties.filter

Information about the filter for the event subscription.

properties.labels
  • string[]

Responses

Name Type Description
201 Created

Created

Other Status Codes

*** Error Responses: ***

  • 400 Bad Request.

  • 500 Internal Server Error.

Examples

EventSubscriptions_CreateForCustomTopic
EventSubscriptions_CreateForResource
EventSubscriptions_CreateForResourceGroup
EventSubscriptions_CreateForSubscription

EventSubscriptions_CreateForCustomTopic

Sample Request

PUT https://management.azure.com/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic1/providers/Microsoft.EventGrid/eventSubscriptions/examplesubscription1?api-version=2017-06-15-preview
{
  "properties": {
    "destination": {
      "endpointType": "WebHook",
      "properties": {
        "endpointUrl": "https://requestb.in/15ksip71"
      }
    },
    "filter": {
      "isSubjectCaseSensitive": false,
      "subjectBeginsWith": "ExamplePrefix",
      "subjectEndsWith": "ExampleSuffix"
    }
  }
}

Sample Response

{
  "properties": {
    "destination": {
      "properties": {
        "endpointBaseUrl": "https://requestb.in/15ksip71"
      },
      "endpointType": "WebHook"
    },
    "filter": {
      "includedEventTypes": [
        "All"
      ],
      "isSubjectCaseSensitive": false,
      "subjectBeginsWith": "ExamplePrefix",
      "subjectEndsWith": "ExampleSuffix"
    },
    "provisioningState": "Succeeded",
    "topic": "/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourceGroups/examplerg/providers/microsoft.eventgrid/topics/exampletopic1"
  },
  "id": "/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic1/providers/Microsoft.EventGrid/eventSubscriptions/examplesubscription1",
  "name": "examplesubscription1",
  "type": "Microsoft.EventGrid/eventSubscriptions"
}

EventSubscriptions_CreateForResource

Sample Request

PUT https://management.azure.com/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourceGroups/examplerg/providers/Microsoft.EventHub/namespaces/examplenamespace1/providers/Microsoft.EventGrid/eventSubscriptions/examplesubscription10?api-version=2017-06-15-preview
{
  "properties": {
    "destination": {
      "endpointType": "WebHook",
      "properties": {
        "endpointUrl": "https://requestb.in/15ksip71"
      }
    },
    "filter": {
      "isSubjectCaseSensitive": false,
      "subjectBeginsWith": "ExamplePrefix",
      "subjectEndsWith": "ExampleSuffix"
    }
  }
}

Sample Response

{
  "properties": {
    "destination": {
      "properties": {
        "endpointBaseUrl": "https://requestb.in/15ksip71"
      },
      "endpointType": "WebHook"
    },
    "filter": {
      "includedEventTypes": [
        "All"
      ],
      "isSubjectCaseSensitive": false,
      "subjectBeginsWith": "ExamplePrefix",
      "subjectEndsWith": "ExampleSuffix"
    },
    "provisioningState": "Succeeded",
    "topic": "/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourceGroups/examplerg/providers/Microsoft.EventHub/namespaces/examplenamespace1"
  },
  "id": "/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourceGroups/examplerg/providers/Microsoft.EventHub/namespaces/examplenamespace1/providers/Microsoft.EventGrid/eventSubscriptions/examplesubscription10",
  "name": "examplesubscription10",
  "type": "Microsoft.EventGrid/eventSubscriptions"
}

EventSubscriptions_CreateForResourceGroup

Sample Request

PUT https://management.azure.com/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourceGroups/examplerg/providers/Microsoft.EventGrid/eventSubscriptions/examplesubscription2?api-version=2017-06-15-preview
{
  "properties": {
    "destination": {
      "endpointType": "WebHook",
      "properties": {
        "endpointUrl": "https://requestb.in/15ksip71"
      }
    },
    "filter": {
      "isSubjectCaseSensitive": false,
      "subjectBeginsWith": "ExamplePrefix",
      "subjectEndsWith": "ExampleSuffix"
    }
  }
}

Sample Response

{
  "properties": {
    "destination": {
      "properties": {
        "endpointBaseUrl": "https://requestb.in/15ksip71"
      },
      "endpointType": "WebHook"
    },
    "filter": {
      "includedEventTypes": [
        "All"
      ],
      "isSubjectCaseSensitive": false,
      "subjectBeginsWith": "ExamplePrefix",
      "subjectEndsWith": "ExampleSuffix"
    },
    "provisioningState": "Succeeded",
    "topic": "/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourceGroups/examplerg"
  },
  "id": "/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourceGroups/examplerg/providers/Microsoft.EventGrid/eventSubscriptions/examplesubscription2",
  "name": "examplesubscription2",
  "type": "Microsoft.EventGrid/eventSubscriptions"
}

EventSubscriptions_CreateForSubscription

Sample Request

PUT https://management.azure.com/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/providers/Microsoft.EventGrid/eventSubscriptions/examplesubscription3?api-version=2017-06-15-preview
{
  "properties": {
    "destination": {
      "endpointType": "WebHook",
      "properties": {
        "endpointUrl": "https://requestb.in/15ksip71"
      }
    },
    "filter": {
      "isSubjectCaseSensitive": false
    }
  }
}

Sample Response

{
  "properties": {
    "destination": {
      "properties": {
        "endpointBaseUrl": "https://requestb.in/15ksip71"
      },
      "endpointType": "WebHook"
    },
    "filter": {
      "includedEventTypes": [
        "All"
      ],
      "isSubjectCaseSensitive": false,
      "subjectBeginsWith": "",
      "subjectEndsWith": ""
    },
    "provisioningState": "Succeeded",
    "topic": "/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4"
  },
  "id": "/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/providers/Microsoft.EventGrid/eventSubscriptions/examplesubscription3",
  "name": "examplesubscription3",
  "type": "Microsoft.EventGrid/eventSubscriptions"
}

Definitions

EndpointType

Type of the endpoint for the event subscription destination

EventSubscription

Event Subscription

EventSubscriptionDestination

Information about the destination where events have to be delivered for the event subscription.

EventSubscriptionFilter

Information about the filter for the event subscription.

EventSubscriptionProvisioningState

Provisioning state of the event subscription.

EndpointType

Type of the endpoint for the event subscription destination

Name Type Description
WebHook
  • string

EventSubscription

Event Subscription

Name Type Description
id
  • string

Fully qualified identifier of the resource

name
  • string

Name of the resource

properties.destination

Information about the destination where events have to be delivered for the event subscription.

properties.filter

Information about the filter for the event subscription.

properties.labels
  • string[]
properties.provisioningState

Provisioning state of the event subscription.

properties.topic
  • string

Name of the topic of the event subscription.

type
  • string

Type of the resource

EventSubscriptionDestination

Information about the destination where events have to be delivered for the event subscription.

Name Type Description
endpointType

Type of the endpoint for the event subscription destination

properties.endpointBaseUrl
  • string

The base URL that represents the endpoint of the destination of an event subscription.

properties.endpointUrl
  • string

The URL that represents the endpoint of the destination of an event subscription.

EventSubscriptionFilter

Information about the filter for the event subscription.

Name Type Description
includedEventTypes
  • string[]
isSubjectCaseSensitive
  • boolean

Specifies if the SubjectBeginsWith and SubjectEndsWith properties of the filter should be compared in a case sensitive manner.

subjectBeginsWith
  • string

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

An optional string to filter events for an event subscription based on a resource path suffix. Wildcard characters are not supported in this path.

EventSubscriptionProvisioningState

Provisioning state of the event subscription.

Name Type Description
Canceled
  • string
Creating
  • string
Deleting
  • string
Failed
  • string
Succeeded
  • string
Updating
  • string