你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

New-AzureRmEventGridSubscription

创建主题、Azure 资源、Azure 订阅或资源组的新Azure 事件网格事件订阅。

警告

截至 2024 年 2 月 29 日,AzureRM PowerShell 模块已正式弃用。 为了确保持续获得支持和更新,建议用户从 AzureRM 迁移到 Az PowerShell 模块。

尽管 AzureRM 模块仍可能正常运行,但它不再维护或受支持,但会根据用户的自由裁量权和风险继续使用任何继续使用模块。 有关过渡到 Az 模块的指导,请参阅我们的迁移资源

语法

New-AzureRmEventGridSubscription
   [-EventSubscriptionName] <String>
   [-Endpoint] <String>
   [[-ResourceGroupName] <String>]
   [[-EndpointType] <String>]
   [[-SubjectBeginsWith] <String>]
   [[-SubjectEndsWith] <String>]
   [-SubjectCaseSensitive]
   [[-IncludedEventType] <String[]>]
   [[-Label] <String[]>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzureRmEventGridSubscription
   [-ResourceId] <String>
   [-EventSubscriptionName] <String>
   [-Endpoint] <String>
   [[-EndpointType] <String>]
   [[-SubjectBeginsWith] <String>]
   [[-SubjectEndsWith] <String>]
   [-SubjectCaseSensitive]
   [[-IncludedEventType] <String[]>]
   [[-Label] <String[]>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzureRmEventGridSubscription
   [-InputObject] <PSTopic>
   [-EventSubscriptionName] <String>
   [-Endpoint] <String>
   [[-EndpointType] <String>]
   [[-SubjectBeginsWith] <String>]
   [[-SubjectEndsWith] <String>]
   [-SubjectCaseSensitive]
   [[-IncludedEventType] <String[]>]
   [[-Label] <String[]>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzureRmEventGridSubscription
   [-EventSubscriptionName] <String>
   [-Endpoint] <String>
   [-ResourceGroupName] <String>
   [-TopicName] <String>
   [[-EndpointType] <String>]
   [[-SubjectBeginsWith] <String>]
   [[-SubjectEndsWith] <String>]
   [-SubjectCaseSensitive]
   [[-IncludedEventType] <String[]>]
   [[-Label] <String[]>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

说明

为Azure 事件网格主题、支持的 Azure 资源、Azure 订阅或资源组创建新事件订阅。 若要创建当前所选 Azure 订阅的事件订阅,请指定事件订阅名称和目标终结点。 若要创建资源组的事件订阅,除了事件订阅名称和目标终结点之外,还指定资源组名称。 若要创建Azure 事件网格主题的事件订阅,请指定主题名称。 若要为受支持的 Azure 资源创建事件订阅,请指定资源的完整资源 ID。 若要查看受支持的类型列表,请运行 Get-AzureRmEventGridTopicType cmdlet。

示例

示例 1

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

使用 webhook 目标终结点https://requestb.in/19qlscd1在资源组“MyResourceGroupName”中创建Azure 事件网格主题“Topic1”的新事件订阅“EventSubscription1”。 此事件订阅使用默认筛选器。

示例 2

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

使用 Webhook 目标终结点 https://requestb.in/19qlscd1创建资源组“MyResourceGroupName”的新事件订阅“EventSubscription1”。 此事件订阅使用默认筛选器。

示例 3

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

使用 Webhook 目标终结点 https://requestb.in/19qlscd1为当前选定的 Azure 订阅创建新的事件订阅“EventSubscription1”。 此事件订阅使用默认筛选器。

示例 4

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

使用 Webhook 目标终结点 https://requestb.in/19qlscd1为当前选定的 Azure 订阅创建新的事件订阅“EventSubscription1”。 此事件订阅指定事件类型和主题的其他筛选器,并且仅将匹配这些筛选器的事件传送到目标终结点。

示例 5

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

创建一个新的事件订阅“EventSubscription1”到当前选定的 Azure 订阅,并将指定的事件中心用作事件的目标。 此事件订阅使用默认筛选器。

示例 6

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

使用指定的 webhhok 目标终结点 https://requestb.in/19qlscd1创建 EventHub 命名空间的新事件订阅“EventSubscription1”。 此事件订阅使用默认筛选器。

参数

-Confirm

提示你在运行 cmdlet 之前进行确认。

类型:SwitchParameter
别名:cf
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-DefaultProfile

用于与 azure 通信的凭据、帐户、租户和订阅

类型:IAzureContextContainer
别名:AzureRmContext, AzureCredential
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-Endpoint

事件订阅目标终结点。 可以是 Webhook URL 或 EventHub 的 Azure 资源 ID。

类型:String
Position:1
默认值:None
必需:True
接受管道输入:True
接受通配符:False

-EndpointType

终结点类型。 这可以是 Webhook 或 eventhub

类型:String
接受的值:webhook, eventhub, webhook, eventhub
Position:4
默认值:None
必需:False
接受管道输入:True
接受通配符:False

-EventSubscriptionName

事件订阅的名称

类型:String
Position:0
默认值:None
必需:True
接受管道输入:True
接受通配符:False

-IncludedEventType

指定要包含的事件类型的列表的筛选器。如果未指定,将包括所有事件类型。

类型:String[]
Position:7
默认值:None
必需:False
接受管道输入:True
接受通配符:False

-InputObject

EventGrid Topic 对象。

类型:PSTopic
Position:0
默认值:None
必需:True
接受管道输入:True
接受通配符:False

-Label

事件订阅的标签

类型:String[]
Position:8
默认值:None
必需:False
接受管道输入:True
接受通配符:False

-ResourceGroupName

主题的资源组。

类型:String
别名:ResourceGroup
Position:2
默认值:None
必需:True
接受管道输入:True
接受通配符:False

-ResourceId

应向其创建事件订阅的资源的标识符。

类型:String
Position:0
默认值:None
必需:True
接受管道输入:True
接受通配符:False

-SubjectBeginsWith

指定仅包含与指定主题前缀匹配的事件的筛选器。 如果未指定,则包含所有主题前缀的事件。

类型:String
Position:5
默认值:None
必需:False
接受管道输入:True
接受通配符:False

-SubjectCaseSensitive

指定应以区分大小写的方式比较主题字段的筛选器。 如果未指定,主题将以不区分大小写的方式进行比较。

类型:SwitchParameter
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-SubjectEndsWith

指定仅包含与指定主题后缀匹配的事件的筛选器。 如果未指定,则包含所有主题后缀的事件。

类型:String
Position:6
默认值:None
必需:False
接受管道输入:True
接受通配符:False

-TopicName

应向其创建事件订阅的主题的名称。

类型:String
Position:3
默认值:None
必需:True
接受管道输入:True
接受通配符:False

-WhatIf

显示运行该 cmdlet 时会发生什么情况。 cmdlet 未运行。

类型:SwitchParameter
别名:wi
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

输入

String

PSTopic

参数:InputObject (ByValue)

String[]

输出

PSEventSubscription