Skip to content

Commit d41be6c

Browse files
committed
Add bicep for connector walkthrough
1 parent cec615d commit d41be6c

File tree

1 file changed

+167
-0
lines changed

1 file changed

+167
-0
lines changed
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
metadata description = 'This template deploys components that are required to show data flowing after cluster provisioning and AIO deployment.'
2+
3+
/*****************************************************************************/
4+
/* Deployment Parameters */
5+
/*****************************************************************************/
6+
7+
param clusterName string
8+
param customLocationName string
9+
param aioExtensionName string
10+
param aioInstanceName string
11+
param aioAssetName string
12+
param resourceSuffix string = substring(uniqueString(subscription().id, resourceGroup().id, clusterName), 0, 10)
13+
param eventHubName string = 'aio-eh-${resourceSuffix}'
14+
param defaultDataflowEndpointName string = 'default'
15+
param defaultDataflowProfileName string = 'default'
16+
param createRoleAssignment bool = true
17+
18+
/*****************************************************************************/
19+
/* Existing AIO cluster */
20+
/*****************************************************************************/
21+
22+
resource connectedCluster 'Microsoft.Kubernetes/connectedClusters@2021-10-01' existing = {
23+
name: clusterName
24+
}
25+
26+
resource customLocation 'Microsoft.ExtendedLocation/customLocations@2021-08-31-preview' existing = {
27+
name: customLocationName
28+
}
29+
30+
resource aioExtension 'Microsoft.KubernetesConfiguration/extensions@2022-11-01' existing = {
31+
name: aioExtensionName
32+
scope: connectedCluster
33+
}
34+
35+
resource aioInstance 'Microsoft.IoTOperations/instances@2025-04-01' existing = {
36+
name: aioInstanceName
37+
}
38+
39+
resource defaultDataflowEndpoint 'Microsoft.IoTOperations/instances/dataflowEndpoints@2025-04-01' existing = {
40+
name: defaultDataflowEndpointName
41+
}
42+
43+
resource defaultDataflowProfile 'Microsoft.IoTOperations/instances/dataflowProfiles@2025-04-01' existing = {
44+
name: defaultDataflowProfileName
45+
parent: aioInstance
46+
}
47+
48+
/*****************************************************************************/
49+
/* Event Hub */
50+
/*****************************************************************************/
51+
52+
resource eventHubNamespace 'Microsoft.EventHub/namespaces@2024-01-01' = {
53+
name: eventHubName
54+
location: resourceGroup().location
55+
properties: {
56+
disableLocalAuth: false
57+
}
58+
}
59+
60+
// Role assignment for Event Hubs Data Sender role
61+
resource roleAssignmentDataSender 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (createRoleAssignment) {
62+
name: guid(eventHubNamespace.id, aioExtension.id, '69b88ce2-a752-421f-bd8b-e230189e1d63')
63+
scope: eventHubNamespace
64+
properties: {
65+
// ID for Event Hubs Data Sender role is 2b629674-e913-4c01-ae53-ef4638d8f975
66+
roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', '2b629674-e913-4c01-ae53-ef4638d8f975')
67+
principalId: aioExtension.identity.principalId
68+
principalType: 'ServicePrincipal'
69+
}
70+
}
71+
72+
resource eventHub 'Microsoft.EventHub/namespaces/eventhubs@2024-01-01' = {
73+
name: 'thermostateh'
74+
parent: eventHubNamespace
75+
properties: {
76+
messageRetentionInDays: 1
77+
partitionCount: 1
78+
}
79+
}
80+
81+
/*****************************************************************************/
82+
/* Data flow */
83+
/*****************************************************************************/
84+
85+
resource dataflowEndpointEventHub 'Microsoft.IoTOperations/instances/dataflowEndpoints@2025-04-01' = {
86+
parent: aioInstance
87+
name: 'thermostat-eh-endpoint'
88+
extendedLocation: {
89+
name: customLocation.id
90+
type: 'CustomLocation'
91+
}
92+
properties: {
93+
endpointType: 'Kafka'
94+
kafkaSettings: {
95+
host: '${eventHubName}.servicebus.windows.net:9093'
96+
batching: {
97+
latencyMs: 0
98+
maxMessages: 100
99+
}
100+
tls: {
101+
mode: 'Enabled'
102+
}
103+
authentication: {
104+
method: 'SystemAssignedManagedIdentity'
105+
systemAssignedManagedIdentitySettings: {
106+
audience: 'https://${eventHubName}.servicebus.windows.net'
107+
}
108+
}
109+
}
110+
}
111+
dependsOn: [
112+
eventHubNamespace
113+
]
114+
}
115+
116+
resource dataflowThermostat 'Microsoft.IoTOperations/instances/dataflowProfiles/dataflows@2025-04-01' = {
117+
parent: defaultDataflowProfile
118+
name: 'thermostat-data-flow'
119+
extendedLocation: {
120+
name: customLocation.id
121+
type: 'CustomLocation'
122+
}
123+
properties: {
124+
mode: 'Enabled'
125+
operations: [
126+
{
127+
operationType: 'Source'
128+
sourceSettings: {
129+
endpointRef: defaultDataflowEndpoint.name
130+
assetRef: aioAssetName
131+
serializationFormat: 'Json'
132+
dataSources: ['machine/thermostat1/status']
133+
}
134+
}
135+
{
136+
operationType: 'BuiltInTransformation'
137+
builtInTransformationSettings: {
138+
serializationFormat: 'Json'
139+
map: [
140+
{
141+
type: 'PassThrough'
142+
inputs: [
143+
'*'
144+
]
145+
output: '*'
146+
}
147+
]
148+
}
149+
}
150+
{
151+
operationType: 'Destination'
152+
destinationSettings: {
153+
endpointRef: dataflowEndpointEventHub.name
154+
dataDestination: 'thermostateh'
155+
}
156+
}
157+
]
158+
}
159+
dependsOn: [
160+
eventHub
161+
]
162+
}
163+
164+
output eventHub object = {
165+
namespace: eventHubNamespace.name
166+
name: eventHub.name
167+
}

0 commit comments

Comments
 (0)