Skip to content

Instantly share code, notes, and snippets.

@timmyreilly
Created November 21, 2018 00:11
Show Gist options
  • Save timmyreilly/dd7e8b36b0f2cf36c0b09f643ab5a7d1 to your computer and use it in GitHub Desktop.
Save timmyreilly/dd7e8b36b0f2cf36c0b09f643ab5a7d1 to your computer and use it in GitHub Desktop.
ARM Template for Azure Storage to create an Event Grid Subscription and point it at and Existing EventHub

Event Grid

Event grid from a new storage account to event hub:

az login
az group create --name ExampleGroup --location "West US"
az group deployment create --name exampleDep --resource-group ExampleGroup --template-file .\event-hub\armStorageToEventHubEndpoint.json

"Please provide string value for 'endpoint' eg: 
/subscriptions/1230123-1234-1234-1234-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.EventHub/namespaces/tim-acceptanceTestEventHubNamespace/eventhubs/tim-testeventhub
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageName": {
"type": "string",
"defaultValue": "[concat('storage', uniqueString(resourceGroup().id))]",
"metadata": {
"description": "Provide a unique name for the Blob Storage account."
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Provide a location for the Blob Storage account that supports Event Grid."
}
},
"eventSubName": {
"type": "string",
"defaultValue": "subToStorage",
"metadata": {
"description": "Provide a name for the Event Grid subscription."
}
},
"endpoint": {
"type": "string",
"metadata": {
"description": "Provide the URL for the WebHook to receive events. eg: Create your own endpoint for events."
}
}
},
"resources": [
{
"name": "[parameters('storageName')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2017-10-01",
"sku": {
"name": "Standard_LRS"
},
"kind": "StorageV2",
"location": "[parameters('location')]",
"tags": {},
"properties": {
"accessTier": "Hot"
}
},
{
"type": "Microsoft.Storage/storageAccounts/providers/eventSubscriptions",
"name": "[concat(parameters('storageName'), '/Microsoft.EventGrid/', parameters('eventSubName'))]",
"apiVersion": "2018-01-01",
"dependsOn": [
"[parameters('storageName')]"
],
"properties": {
"destination": {
"endpointType": "EventHub",
"properties": {
"resourceId": "[parameters('endpoint')]"
}
},
"filter": {
"subjectBeginsWith": "",
"subjectEndsWith": "",
"isSubjectCaseSensitive": false,
"includedEventTypes": [
"All"
]
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment