Skip to content

Commit 44b4295

Browse files
authored
Add bicep for connector walkthrough (#169)
## Purpose <!-- Describe the intention of the changes being proposed. What problem does it solve or functionality does it add? --> Add a bicep file to deploy resources used to verify that a custom connector is working ## Does this introduce a breaking change? <!-- Mark one with an "x". --> ``` [ ] Yes [x] No ``` ## Pull Request Type What kind of change does this Pull Request introduce? <!-- Please check the one that applies to this PR using "x". --> ``` [ ] Bugfix [ ] Feature [ ] Code style update (formatting, local variables) [ ] Refactoring (no functional changes, no api changes) [x] Documentation content changes [ ] Other... Please describe: ```
1 parent 8c2892c commit 44b4295

1 file changed

Lines changed: 173 additions & 0 deletions

File tree

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
metadata description = 'This template deploys components that are required to verify that the custom HTTP/REST connector created in the docs walkthrough is working as expected. Specific components are Event Hubs namespace an data flow'
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+
sku: {
56+
name: 'Standard'
57+
tier: 'Standard'
58+
capacity: 1
59+
}
60+
properties: {
61+
disableLocalAuth: true
62+
minimumTlsVersion: '1.2'
63+
}
64+
}
65+
66+
// Role assignment for Event Hubs Data Sender role
67+
resource roleAssignmentDataSender 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (createRoleAssignment) {
68+
name: guid(eventHubNamespace.id, aioExtension.id, '69b88ce2-a752-421f-bd8b-e230189e1d63')
69+
scope: eventHubNamespace
70+
properties: {
71+
// ID for Event Hubs Data Sender role is 2b629674-e913-4c01-ae53-ef4638d8f975
72+
roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', '2b629674-e913-4c01-ae53-ef4638d8f975')
73+
principalId: aioExtension.identity.principalId
74+
principalType: 'ServicePrincipal'
75+
}
76+
}
77+
78+
resource eventHub 'Microsoft.EventHub/namespaces/eventhubs@2024-01-01' = {
79+
name: 'thermostateh'
80+
parent: eventHubNamespace
81+
properties: {
82+
messageRetentionInDays: 1
83+
partitionCount: 1
84+
}
85+
}
86+
87+
/*****************************************************************************/
88+
/* Data flow */
89+
/*****************************************************************************/
90+
91+
resource dataflowEndpointEventHub 'Microsoft.IoTOperations/instances/dataflowEndpoints@2025-04-01' = {
92+
parent: aioInstance
93+
name: 'thermostat-eh-endpoint'
94+
extendedLocation: {
95+
name: customLocation.id
96+
type: 'CustomLocation'
97+
}
98+
properties: {
99+
endpointType: 'Kafka'
100+
kafkaSettings: {
101+
host: '${eventHubName}.servicebus.windows.net:9093'
102+
batching: {
103+
latencyMs: 0
104+
maxMessages: 100
105+
}
106+
tls: {
107+
mode: 'Enabled'
108+
}
109+
authentication: {
110+
method: 'SystemAssignedManagedIdentity'
111+
systemAssignedManagedIdentitySettings: {
112+
audience: 'https://${eventHubName}.servicebus.windows.net'
113+
}
114+
}
115+
}
116+
}
117+
dependsOn: [
118+
eventHubNamespace
119+
]
120+
}
121+
122+
resource dataflowThermostat 'Microsoft.IoTOperations/instances/dataflowProfiles/dataflows@2025-04-01' = {
123+
parent: defaultDataflowProfile
124+
name: 'thermostat-data-flow'
125+
extendedLocation: {
126+
name: customLocation.id
127+
type: 'CustomLocation'
128+
}
129+
properties: {
130+
mode: 'Enabled'
131+
operations: [
132+
{
133+
operationType: 'Source'
134+
sourceSettings: {
135+
endpointRef: defaultDataflowEndpoint.name
136+
assetRef: aioAssetName
137+
serializationFormat: 'Json'
138+
dataSources: ['machine/thermostat1/status']
139+
}
140+
}
141+
{
142+
operationType: 'BuiltInTransformation'
143+
builtInTransformationSettings: {
144+
serializationFormat: 'Json'
145+
map: [
146+
{
147+
type: 'PassThrough'
148+
inputs: [
149+
'*'
150+
]
151+
output: '*'
152+
}
153+
]
154+
}
155+
}
156+
{
157+
operationType: 'Destination'
158+
destinationSettings: {
159+
endpointRef: dataflowEndpointEventHub.name
160+
dataDestination: 'thermostateh'
161+
}
162+
}
163+
]
164+
}
165+
dependsOn: [
166+
eventHub
167+
]
168+
}
169+
170+
output eventHub object = {
171+
namespace: eventHubNamespace.name
172+
name: eventHub.name
173+
}

0 commit comments

Comments
 (0)