Skip to content

Commit

Permalink
add eventhubs
Browse files Browse the repository at this point in the history
  • Loading branch information
jmservera committed Apr 16, 2024
1 parent 18c277b commit 82484d0
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 3 deletions.
15 changes: 15 additions & 0 deletions eventgrid/templates/eventgrid.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ resource namespace_resource 'Microsoft.EventGrid/namespaces@2023-12-15-preview'
}
}

// ********************************************************************************************************************
// * Create client groups
// ********************************************************************************************************************

resource namespace_group_c2d_publishers 'Microsoft.EventGrid/namespaces/clientGroups@2023-12-15-preview' = {
parent: namespace_resource
name: 'publishers'
Expand Down Expand Up @@ -60,6 +64,10 @@ resource namespace_group_devices 'Microsoft.EventGrid/namespaces/clientGroups@20
}
}

// ********************************************************************************************************************
// * Create permission bindings
// ********************************************************************************************************************

resource namespace_telemetrypublish 'Microsoft.EventGrid/namespaces/permissionBindings@2023-12-15-preview' = {
parent: namespace_resource
name: 'telemetrypublish'
Expand Down Expand Up @@ -110,6 +118,9 @@ resource namespace_test 'Microsoft.EventGrid/namespaces/topics@2023-12-15-previe
}
}

// ********************************************************************************************************************
// * Create topic spaces
// ********************************************************************************************************************
resource namespace_topic_spaces_data 'Microsoft.EventGrid/namespaces/topicSpaces@2023-12-15-preview' = {
parent: namespace_resource
name: 'data'
Expand All @@ -131,6 +142,10 @@ resource namespace_topic_spaces_devices 'Microsoft.EventGrid/namespaces/topicSpa
}
}

// ********************************************************************************************************************
// * Create clients
// ********************************************************************************************************************

module eventgrid_clients 'modules/eventgrid_clients.bicep' = {
name: 'clients'
params: {
Expand Down
57 changes: 57 additions & 0 deletions eventgrid/templates/eventhubs.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
param eventhub_namespace_name string = 'jmeventgrid'
param eventhub_name string = 'eventgridsink'
param location string = resourceGroup().location

resource eventhub_namespace 'Microsoft.EventHub/namespaces@2023-01-01-preview' = {
name: eventhub_namespace_name
location: location
sku: {
name: 'Basic'
tier: 'Basic'
capacity: 1
}
properties: {
minimumTlsVersion: '1.2'
publicNetworkAccess: 'Enabled'
disableLocalAuth: false
privateEndpointConnections: []
zoneRedundant: true
isAutoInflateEnabled: false
maximumThroughputUnits: 0
kafkaEnabled: true
}
}



resource eventhubs_eventgridsink 'Microsoft.EventHub/namespaces/eventhubs@2023-01-01-preview' = {
parent: eventhub_namespace
name: eventhub_name
properties: {
retentionDescription: {
cleanupPolicy: 'Delete'
retentionTimeInHours: 1
}
messageRetentionInDays: 1
partitionCount: 1
status: 'Active'
}
}

// resource namespaces_jmevgrid_name_default 'Microsoft.EventHub/namespaces/networkrulesets@2023-01-01-preview' = {
// parent: namespaces_jmevgrid_name_resource
// name: 'default'
// properties: {
// publicNetworkAccess: 'Enabled'
// defaultAction: 'Allow'
// virtualNetworkRules: []
// ipRules: []
// trustedServiceAccessEnabled: false
// }
// }

// resource namespaces_jmevgrid_name_evengridsink_Default 'Microsoft.EventHub/namespaces/eventhubs/consumergroups@2023-01-01-preview' = {
// parent: namespaces_jmevgrid_name_evengridsink
// name: '$Default'
// properties: {}
// }
4 changes: 2 additions & 2 deletions eventgrid/templates/parameters.bicepparam
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using 'eventgrid.bicep'
using 'template.bicep'

param namespaces_name = 'jmioteventgridns'
param name_base = 'jmioteventgridns'
param clients = [
{
name: 'client1'
Expand Down
2 changes: 1 addition & 1 deletion eventgrid/templates/parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"namespaces_name": {
"name_base": {
"value": "jmioteventgridns"
},
"clients": {
Expand Down
33 changes: 33 additions & 0 deletions eventgrid/templates/template.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@description('Specifies the location for resources.')
param location string = resourceGroup().location
@description('The name of the Event Grid namespace.')
param name_base string = 'jmeventgrid'
@description('An array containing the clients that will be allowed to interact with the Event Grid namespace. Each client must have a name, a thumbprint, and a role. The role can be either "service" or "device".')
param clients array = [
{
name: 'name of client'
thumbprint: 'base64 encoded thumbprint'
role: 'service or device'
}
]

module eventgrid 'eventgrid.bicep' = {
name: 'clients'
params: {
location: location
namespaces_name: name_base
clients: clients
}
}

module eventhub 'eventhubs.bicep' = {
name: 'eventhub'
params: {
location: location
eventhub_namespace_name: name_base
eventhub_name: '${name_base}sink'
}
}

output namespace_mqtt_hostname string = eventgrid.outputs.namespace_mqtt_hostname

0 comments on commit 82484d0

Please sign in to comment.