Skip to content

Latest commit

 

History

History
42 lines (27 loc) · 1.85 KB

File metadata and controls

42 lines (27 loc) · 1.85 KB
title Azure PowerShell - subscribe to resource group
description This article provides a sample Azure PowerShell script that shows how to subscribe to Event Grid events for a resource group and filter for a resource.
ms.devlang powershell
ms.custom devx-track-azurepowershell
ms.topic sample
ms.date 09/15/2021

Subscribe to events for a resource group and filter for a resource with PowerShell

This script creates an Event Grid subscription to the events for a resource group. It uses a filter to get only events for a specified resource in the resource group.

[!INCLUDE quickstarts-free-trial-note]

Sample script - stable

[!INCLUDE updated-for-az]

[!code-powershellmain]

Sample script - preview module

[!INCLUDE requires-azurerm]

The preview sample script requires the Event Grid module. To install, run Install-Module -Name AzureRM.EventGrid -AllowPrerelease -Force -Repository PSGallery

[!code-powershellmain]

Script explanation

This script uses the following command to create the event subscription. Each command in the table links to command-specific documentation.

Command Notes
New-AzEventGridSubscription Create an Event Grid subscription.

Next steps