Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

added preview examples #153

Merged
merged 26 commits into from Dec 10, 2018
Merged
11 changes: 7 additions & 4 deletions event-grid/create-custom-topic/create-custom-topic.ps1
@@ -1,15 +1,18 @@
# Give your custom topic a unique name
$myTopic = "demoContosoTopic"

# Provice name for resource group
$myResourceGroup=demoResourceGroup
tfitzmac marked this conversation as resolved.
Show resolved Hide resolved

# Create resource group
New-AzureRmResourceGroup -Name myResourceGroup -Location westus2
New-AzureRmResourceGroup -Name $myResourceGroup -Location westus2

# Create custom topic
New-AzureRmEventGridTopic -ResourceGroupName myResourceGroup -Location westus2 -Name $myTopic
New-AzureRmEventGridTopic -ResourceGroupName $myResourceGroup -Name $myTopic -Location westus2

# Retrieve endpoint and key to use when publishing to the topic
$endpoint = (Get-AzureRmEventGridTopic -ResourceGroupName myResourceGroup -Name $myTopic).Endpoint
$key = (Get-AzureRmEventGridTopicKey -ResourceGroupName myResourceGroup3 -Name $myTopic).Key1
$endpoint = (Get-AzureRmEventGridTopic -ResourceGroupName $myResourceGroup -Name $myTopic).Endpoint
$key = (Get-AzureRmEventGridTopicKey -ResourceGroupName $myResourceGroup3 -Name $myTopic).Key1
tfitzmac marked this conversation as resolved.
Show resolved Hide resolved

$endpoint
$key
34 changes: 34 additions & 0 deletions event-grid/filter-events-preview/filter-events-preview.ps1
@@ -0,0 +1,34 @@
# You must have the latest version of the Event Grid PowerShell module.
# To install:
# Install-Module -Name AzureRM.EventGrid -AllowPrerelease -Force -Repository PSGallery

# Provide an endpoint for handling the events.
$myEndpoint = "<endpoint URL>"

# Provide the name of the custom topic to create
$topicName = "<your-topic-name>"

# Provide the name of the resource group to contain the custom topic
$myResourceGroup= "<resource-group>"

# Select the Azure subscription that contains the resource group.
tfitzmac marked this conversation as resolved.
Show resolved Hide resolved
Set-AzureRmContext -Subscription "Contoso Subscription"
tfitzmac marked this conversation as resolved.
Show resolved Hide resolved

# Create the resource group
New-AzureRmResourceGroup -Name $myResourceGroup -Location eastus2

# Create custom topic
New-AzureRmEventGridTopic -ResourceGroupName $myResourceGroup -Location eastus2 -Name $topicName

# Get resource ID of custom topic
$topicid = (Get-AzureRmEventGridTopic -ResourceGroupName $myResourceGroup -Name $topicName).Id

# Set the operator type, field and values for the filtering
$AdvFilter1=@{operator="StringIn"; key="Data.color"; Values=@('blue', 'red', 'green')}

# Subscribe to the custom topic. Filter based on a value in the event data.
New-AzureRmEventGridSubscription `
-ResourceId $topicid `
-EventSubscriptionName demoSubWithFilter `
-Endpoint $endpointURL `
tfitzmac marked this conversation as resolved.
Show resolved Hide resolved
-AdvancedFilter @($AdvFilter1)
15 changes: 15 additions & 0 deletions event-grid/filter-events/filter-events.ps1
@@ -0,0 +1,15 @@
# Provide an endpoint for handling the events.
$myEndpoint = "<endpoint URL>"

# Select the Azure subscription that contains the resource group.
Set-AzureRmContext -Subscription "Contoso Subscription"
tfitzmac marked this conversation as resolved.
Show resolved Hide resolved

# Get the resource ID to filter events
$resourceId = (Get-AzureRmResource -ResourceName demoSecurityGroup -ResourceGroupName myResourceGroup).ResourceId
tfitzmac marked this conversation as resolved.
Show resolved Hide resolved

# Subscribe to the resource group. Provide the name of the resource group you want to subscribe to.
New-AzureRmEventGridSubscription `
-Endpoint $myEndpoint `
-EventSubscriptionName demoSubscriptionToResourceGroup `
-ResourceGroupName myResourceGroup `
-SubjectBeginsWith $resourceId
@@ -0,0 +1,15 @@
# You must have the latest version of the Event Grid PowerShell module.
# To install:
# Install-Module -Name AzureRM.EventGrid -AllowPrerelease -Force -Repository PSGallery

# Provide an endpoint for handling the events.
$myEndpoint = "<endpoint URL>"

# Select the Azure subscription you want to subscribe to.
Set-AzureRmContext -Subscription "Contoso Subscription"
tfitzmac marked this conversation as resolved.
Show resolved Hide resolved

# Get the subscription ID
$subID = (Get-AzureRmSubscription -SubscriptionName "Contoso Subscription").Id
tfitzmac marked this conversation as resolved.
Show resolved Hide resolved

# Subscribe to the Azure subscription. The command creates the subscription for the currently selected Azure subscription.
New-AzureRmEventGridSubscription -ResourceId "/subscriptions/$subID" -Endpoint $myEndpoint -EventSubscriptionName demoSubscriptionToAzureSub
Expand Up @@ -4,19 +4,22 @@ $storageName = "contosostorage"
# Provide an endpoint for handling the events.
$myEndpoint = "<endpoint URL>"
tfitzmac marked this conversation as resolved.
Show resolved Hide resolved

# Provide the name of the resource group to contain the storage account.
$myResourceGroup="<resource group name>"

# Create resource group
New-AzureRmResourceGroup -Name myResourceGroup -Location westus2
New-AzureRmResourceGroup -Name $myResourceGroup -Location westus2
tfitzmac marked this conversation as resolved.
Show resolved Hide resolved

# Create the Blob storage account.
New-AzureRmStorageAccount -ResourceGroupName myResourceGroup `
New-AzureRmStorageAccount -ResourceGroupName $myResourceGroup `
tfitzmac marked this conversation as resolved.
Show resolved Hide resolved
-Name $storageName `
-Location westus2 `
-SkuName Standard_LRS `
-Kind BlobStorage `
-AccessTier Hot

# Get the resource ID of the Blob storage account.
$storageId = (Get-AzureRmStorageAccount -ResourceGroupName myResourceGroup -AccountName $storageName).Id
$storageId = (Get-AzureRmStorageAccount -ResourceGroupName $myResourceGroup -AccountName $storageName).Id

# Subscribe to the Blob storage account.
New-AzureRmEventGridSubscription `
Expand Down
@@ -0,0 +1,21 @@
# You must have the latest version of the Event Grid PowerShell module.
# To install:
# Install-Module -Name AzureRM.EventGrid -AllowPrerelease -Force -Repository PSGallery

# Provide the name of the topic you are subscribing to
$myTopic = "demoContosoTopic"

# Provide an endpoint for handling the events.
$myEndpoint = "<endpoint URL>"

# Provide the name of the resource group containing the custom topic.
$myResourceGroup = "demoResourceGroup"
tfitzmac marked this conversation as resolved.
Show resolved Hide resolved

# Get the resource ID of the custom topic
$topicID = (Get-AzureRmEventGridTopic -Name $myTopic -ResourceGroupName $myResourceGroup).Id

# Subscribe to the custom event. Include the resource group that contains the custom topic.
New-AzureRmEventGridSubscription `
-ResourceId $topicID
tfitzmac marked this conversation as resolved.
Show resolved Hide resolved
-EventSubscriptionName demoSubscription `
-Endpoint $myEndpoint
Expand Up @@ -4,10 +4,12 @@ $myTopic = "demoContosoTopic"
# Provide an endpoint for handling the events.
$myEndpoint = "<endpoint URL>"

# Subscribe to the custom event. Include the resource group that contains the custom topic.
# Provide the name of the resource group containing the custom topic.
$myResourceGroup="demoResourceGroup"

# Subscribe to the custom event. Include the resource group that contains the custom topic.
New-AzureRmEventGridSubscription `
-EventSubscriptionName demoSubscription `
-Endpoint $myEndpoint `
-ResourceGroupName myResourceGroup `
-ResourceGroupName $myResourceGroup `
-TopicName $myTopic
@@ -0,0 +1,21 @@
# You must have the latest version of the Event Grid PowerShell module.
# To install:
# Install-Module -Name AzureRM.EventGrid -AllowPrerelease -Force -Repository PSGallery

# Provide an endpoint for handling the events.
$myEndpoint = "<endpoint URL>"

# Provide the name of the resource group to subscribe to.
$myResourceGroup = "<resource group name>"

# Select the Azure subscription that contains the resource group.
Set-AzureRmContext -Subscription "Contoso Subscription"

# Get resource ID of the resource group.
$resourceGroupID = (Get-AzureRmResourceGroup -Name $myResourceGroup).ResourceId

# Subscribe to the resource group. Provide the name of the resource group you want to subscribe to.
New-AzureRmEventGridSubscription `
-ResourceId $resourceGroupID
tfitzmac marked this conversation as resolved.
Show resolved Hide resolved
-Endpoint $myEndpoint `
-EventSubscriptionName demoSubscriptionToResourceGroup
@@ -1,11 +1,14 @@
# Provide an endpoint for handling the events.
$myEndpoint = "<endpoint URL>"

# Provide the name of the resource group to subscribe to.
$myResourceGroup="<resource group name>"

# Select the Azure subscription that contains the resource group.
Set-AzureRmContext -Subscription "Contoso Subscription"

# Subscribe to the resource group. Provide the name of the resource group you want to subscribe to.
New-AzureRmEventGridSubscription `
-Endpoint $myEndpoint `
-EventSubscriptionName demoSubscriptionToResourceGroup `
-ResourceGroupName myResourceGroup
-ResourceGroupName $myResourceGroup