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
destination

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

filter

Information about the filter for the event subscription.

labels
  • string[]

List of user defined labels.

Responses

Name Type Description
201 Created

Created

Other Status Codes

*** Error Responses: ***

  • 400 Bad Request.

  • 500 Internal Server Error.

Examples

EventSubscriptions_CreateForSubscription
EventSubscriptions_CreateForResourceGroup
EventSubscriptions_CreateForResource
EventSubscriptions_CreateForCustomTopic

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

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

Definitions

EndpointType

Type of the endpoint for the event subscription destination

EventSubscription
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.

Type of the endpoint for the event subscription destination

Name Description
WebHook
Name Type Description
destination

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

filter

Information about the filter for the event subscription.

id
  • string

Fully qualified identifier of the resource

labels
  • string[]

List of user defined labels.

name
  • string

Name of the resource

provisioningState

Provisioning state of the event subscription.

topic
  • string

Name of the topic of the event subscription.

type
  • string

Type of the resource

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

Name Type Description
endpointBaseUrl
  • string

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

endpointType

Type of the endpoint for the event subscription destination

endpointUrl
  • string

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

Information about the filter for the event subscription.

Name Type Description
includedEventTypes
  • string[]

A list of applicable event types that need to be part of the event subscription. If it is desired to subscribe to all event types, the string "all" needs to be specified as an element in this list.

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.

Provisioning state of the event subscription.

Name Description
Canceled
Creating
Deleting
Failed
Succeeded
Updating