New-AzEventGridSubscription

Creates a new Azure Event Grid Event Subscription to a topic, Azure resource, Azure subscription or Resource Group.

Syntax

New-AzEventGridSubscription
   [-EventSubscriptionName] <String>
   [-Endpoint] <String>
   [[-ResourceGroupName] <String>]
   [[-EndpointType] <String>]
   [[-SubjectBeginsWith] <String>]
   [[-SubjectEndsWith] <String>]
   [-SubjectCaseSensitive]
   [[-IncludedEventType] <String[]>]
   [[-Label] <String[]>]
   [-EventTtl <Int32>]
   [-MaxDeliveryAttempt <Int32>]
   [-DeadLetterEndpoint <String>]
   [-ExpirationDate <DateTime>]
   [-AdvancedFilter <Hashtable[]>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzEventGridSubscription
   [-ResourceId] <String>
   [-EventSubscriptionName] <String>
   [-Endpoint] <String>
   [[-EndpointType] <String>]
   [[-SubjectBeginsWith] <String>]
   [[-SubjectEndsWith] <String>]
   [-SubjectCaseSensitive]
   [[-IncludedEventType] <String[]>]
   [[-Label] <String[]>]
   [-EventTtl <Int32>]
   [-MaxDeliveryAttempt <Int32>]
   [-DeadLetterEndpoint <String>]
   [-ExpirationDate <DateTime>]
   [-AdvancedFilter <Hashtable[]>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzEventGridSubscription
   [-InputObject] <PSTopic>
   [-EventSubscriptionName] <String>
   [-Endpoint] <String>
   [[-EndpointType] <String>]
   [[-SubjectBeginsWith] <String>]
   [[-SubjectEndsWith] <String>]
   [-SubjectCaseSensitive]
   [[-IncludedEventType] <String[]>]
   [[-Label] <String[]>]
   [-EventTtl <Int32>]
   [-MaxDeliveryAttempt <Int32>]
   [-DeadLetterEndpoint <String>]
   [-ExpirationDate <DateTime>]
   [-AdvancedFilter <Hashtable[]>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzEventGridSubscription
   [-DomainInputObject] <PSDomain>
   [-EventSubscriptionName] <String>
   [-Endpoint] <String>
   [[-EndpointType] <String>]
   [[-SubjectBeginsWith] <String>]
   [[-SubjectEndsWith] <String>]
   [-SubjectCaseSensitive]
   [[-IncludedEventType] <String[]>]
   [[-Label] <String[]>]
   [-EventTtl <Int32>]
   [-MaxDeliveryAttempt <Int32>]
   [-DeadLetterEndpoint <String>]
   [-ExpirationDate <DateTime>]
   [-AdvancedFilter <Hashtable[]>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzEventGridSubscription
   [-DomainTopicInputObject] <PSDomainTopic>
   [-EventSubscriptionName] <String>
   [-Endpoint] <String>
   [[-EndpointType] <String>]
   [[-SubjectBeginsWith] <String>]
   [[-SubjectEndsWith] <String>]
   [-SubjectCaseSensitive]
   [[-IncludedEventType] <String[]>]
   [[-Label] <String[]>]
   [-EventTtl <Int32>]
   [-MaxDeliveryAttempt <Int32>]
   [-DeadLetterEndpoint <String>]
   [-ExpirationDate <DateTime>]
   [-AdvancedFilter <Hashtable[]>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzEventGridSubscription
   [-EventSubscriptionName] <String>
   [-Endpoint] <String>
   [-ResourceGroupName] <String>
   [-TopicName] <String>
   [[-EndpointType] <String>]
   [[-SubjectBeginsWith] <String>]
   [[-SubjectEndsWith] <String>]
   [-SubjectCaseSensitive]
   [[-IncludedEventType] <String[]>]
   [[-Label] <String[]>]
   [-EventTtl <Int32>]
   [-MaxDeliveryAttempt <Int32>]
   [-DeadLetterEndpoint <String>]
   [-ExpirationDate <DateTime>]
   [-AdvancedFilter <Hashtable[]>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzEventGridSubscription
   [-EventSubscriptionName] <String>
   [-Endpoint] <String>
   [-ResourceGroupName] <String>
   [-DomainName] <String>
   [[-EndpointType] <String>]
   [[-SubjectBeginsWith] <String>]
   [[-SubjectEndsWith] <String>]
   [-SubjectCaseSensitive]
   [[-IncludedEventType] <String[]>]
   [[-Label] <String[]>]
   [-EventTtl <Int32>]
   [-MaxDeliveryAttempt <Int32>]
   [-DeadLetterEndpoint <String>]
   [-ExpirationDate <DateTime>]
   [-AdvancedFilter <Hashtable[]>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzEventGridSubscription
   [-EventSubscriptionName] <String>
   [-Endpoint] <String>
   [-ResourceGroupName] <String>
   [-DomainName] <String>
   -DomainTopicName <String>
   [[-EndpointType] <String>]
   [[-SubjectBeginsWith] <String>]
   [[-SubjectEndsWith] <String>]
   [-SubjectCaseSensitive]
   [[-IncludedEventType] <String[]>]
   [[-Label] <String[]>]
   [-EventTtl <Int32>]
   [-MaxDeliveryAttempt <Int32>]
   [-DeadLetterEndpoint <String>]
   [-ExpirationDate <DateTime>]
   [-AdvancedFilter <Hashtable[]>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

Create a new event subscription to an Azure Event Grid topic, a supported Azure resource, an Azure subscription or Resource Group. To create an event subscription to the currently selected Azure subscription, specify the event subscription name and the destination endpoint. To create an event subscription to a resource group, specify the resource group name in addition to the event subscription name and the destination endpoint. To create an event subscription to an Azure Event Grid topic, specify the topic name as well. To create an event subscription to a supported Azure resource, specify the full resource ID of the resource. To view the list of supported types, run the Get-AzEventGridTopicType cmdlet.

Examples

Example 1

PS C:\> New-AzEventGridSubscription -ResourceGroup MyResourceGroup -TopicName Topic1 -Endpoint https://requestb.in/19qlscd1 -EventSubscriptionName EventSubscription1

Creates a new event subscription `EventSubscription1` to an Azure Event Grid topic `Topic1` in resource group `MyResourceGroupName` with the webhook destination endpoint https://requestb.in/19qlscd1. This event subscription uses default filters.

Example 2

PS C:\> New-AzEventGridSubscription -ResourceGroup MyResourceGroupName -Endpoint https://requestb.in/19qlscd1 -EventSubscriptionName EventSubscription1

Creates a new event subscription `EventSubscription1` to a resource group `MyResourceGroupName` with the webhook destination endpoint https://requestb.in/19qlscd1. This event subscription uses default filters.

Example 3

PS C:\> New-AzEventGridSubscription -Endpoint https://requestb.in/19qlscd1 -EventSubscriptionName EventSubscription1

Creates a new event subscription `EventSubscription1` to the currently selected Azure subscription with the webhook destination endpoint https://requestb.in/19qlscd1. This event subscription uses default filters.

Example 4

PS C:\> $includedEventTypes = "Microsoft.Resources.ResourceWriteFailure", "Microsoft.Resources.ResourceWriteSuccess"
PS C:\> $labels = "Finance", "HR"
PS C:\> New-AzEventGridSubscription -Endpoint https://requestb.in/19qlscd1 -EventSubscriptionName EventSubscription1 -SubjectBeginsWith "TestPrefix" -SubjectEndsWith "TestSuffix" -IncludedEventType $includedEventTypes -Label $labels

Creates a new event subscription `EventSubscription1` to the currently selected Azure subscription with the webhook destination endpoint https://requestb.in/19qlscd1. This event subscription specifies the additional filters for event types and subject, and only events matching those filters will be delivered to the destination endpoint.

Example 5

PS C:\> New-AzEventGridSubscription -EventSubscriptionName EventSubscription1 -EndpointType "eventhub" -Endpoint "/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.EventHub/namespaces/ContosoNamespace/eventhubs/EH1"

Creates a new event subscription `EventSubscription1` to the currently selected Azure subscription with the specified event hub as the destination for events. This event subscription uses default filters.

Example 6

PS C:\> New-AzEventGridSubscription -ResourceId "/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.EventHub/namespaces/ContosoNamespace" -Endpoint https://requestb.in/19qlscd1 -EventSubscriptionName EventSubscription1

Creates a new event subscription `EventSubscription1` to an EventHub namespace with the specified webhook destination endpoint https://requestb.in/19qlscd1. This event subscription uses default filters.

Parameters

-AdvancedFilter

Advanced filter that specifies an array of multiple Hashtable values that are used for the attribute-based filtering. Each Hashtable value has the following keys-value info: Operation, Key and Value or Values. Operator can be one of the following values: NumberIn, NumberNotIn, NumberLessThan, NumberGreaterThan, NumberLessThanOrEquals, NumberGreaterThanOrEquals, BoolEquals, StringIn, StringNotIn, StringBeginsWith, StringEndsWith or StringContains. Key represents the payload property where the advanced filtering policies are applied. Finally, Value or Values represent the value or set of values to be matched. This can be a single value of the corresponding type or an array of values. As an example of the advanced filter parameters: $AdvancedFilters=@($AdvFilter1, $AdvFilter2) where $AdvFilter1=@{operator="NumberIn"; key="Data.Key1"; Values=@(1,2)} and $AdvFilter2=@{operator="StringBringsWith"; key="Subject"; Values=@("SubjectPrefix1","SubjectPrefix2")}

Type:System.Collections.Hashtable[]
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-DeadLetterEndpoint

The endpoint used for storing undelivered events. Specify the Azure resource ID of a Storage blob container. For example: /subscriptions/[SubscriptionId]/resourceGroups/[ResourceGroupName]/providers/Microsoft.Storage/storageAccounts/[StorageAccountName]/blobServices/default/containers/[ContainerName].

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure

Type:Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-DomainInputObject

EventGrid Domain object.

Type:Microsoft.Azure.Commands.EventGrid.Models.PSDomain
Position:0
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-DomainName

The name of the Event Grid domain to which the event subscription should be created.

Type:String
Position:3
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-DomainTopicInputObject

EventGrid Domain Topic object.

Type:Microsoft.Azure.Commands.EventGrid.Models.PSDomainTopic
Position:0
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-DomainTopicName

The name of the domain topic to which the event subscription should be created.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Endpoint

Event subscription destination endpoint. This can be a webhook URL, or the Azure resource ID of an EventHub, storage queue, hybridconnection or servicebusqueue. For example, the resource ID for a hybrid connection takes the following form: /subscriptions/[Azure Subscription ID]/resourceGroups/[ResourceGroupName]/providers/Microsoft.Relay/namespaces/[NamespaceName]/hybridConnections/[HybridConnectionName]. It is expected that the destination endpoint to be created and available for use before executing any Event Grid cmdlets.

Type:String
Position:1
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-EndpointType

Endpoint Type. This can be webhook, eventhub, storagequeue, hybridconnection or servicebusqueue. Default value is webhook.

Type:String
Accepted values:webhook, eventhub, storagequeue, hybridconnection, servicebusqueue, webhook, eventhub, storagequeue, hybridconnection, servicebusqueue
Position:4
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-EventSubscriptionName

The name of the event subscription

Type:String
Position:0
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-EventTtl

The time in minutes for the event delivery. This value must be between 1 and 1440

Type:Int32
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ExpirationDate

Determines the expiration DateTime for the event subscription after which event subscription will retire.

Type:DateTime
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-IncludedEventType

Filter that specifies a list of event types to include.If not specified, all event types will be included.

Type:System.String[]
Position:7
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-InputObject

EventGrid Topic object.

Type:PSTopic
Position:0
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-Label

Labels for the event subscription

Type:System.String[]
Position:8
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-MaxDeliveryAttempt

The maximum number of attempts to deliver the event. This value must be between 1 and 30

Type:Int32
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ResourceGroupName

The resource group of the topic.

Type:String
Aliases:ResourceGroup
Position:2
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ResourceId

The identifier of the resource to which the event subscription should be created.

Type:String
Position:0
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-SubjectBeginsWith

Filter that specifies that only events matching the specified subject prefix will be included. If not specified, events with all subject prefixes will be included.

Type:String
Position:5
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-SubjectCaseSensitive

Filter that specifies that the subject field should be compared in a case sensitive manner. If not specified, subject will be compared in a case insensitive manner.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-SubjectEndsWith

Filter that specifies that only events matching the specified subject suffix will be included. If not specified, events with all subject suffixes will be included.

Type:String
Position:6
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-TopicName

The name of the topic to which the event subscription should be created.

Type:String
Position:3
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Inputs

String

PSTopic

Microsoft.Azure.Commands.EventGrid.Models.PSDomain

Microsoft.Azure.Commands.EventGrid.Models.PSDomainTopic

System.String[]

Int32

Outputs

PSEventSubscription