Skip to content

Commit fb3a8be

Browse files
authored
ADT: e2e: Fix bicep file (Azure#22644)
1 parent b314648 commit fb3a8be

File tree

7 files changed

+108
-162
lines changed

7 files changed

+108
-162
lines changed

sdk/digitaltwins/Azure.DigitalTwins.Core/tests/prerequisites/manifest.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

sdk/digitaltwins/Azure.DigitalTwins.Core/tests/prerequisites/prerequisite readme.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,21 @@
1414
### Install Bicep
1515

1616
- Install using the instructions in [bicep](https://github.com/Azure/bicep/blob/main/docs/installing.md)
17+
- Note that to deploy Bicep files, use Bicep CLI version 0.3.1 or later. To check your Bicep CLI version, run:
18+
19+
```bash
20+
bicep --version
21+
```
1722

1823
### Run the setup script
1924

20-
The script outputs [test-resources.bicep](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/digitaltwins/test-resources_needs_fixing.bicep) file in the root folder [digitaltwins](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/digitaltwins)
25+
The script outputs [test-resources.bicep](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/digitaltwins/test-resources.bicep) file in the root folder [digitaltwins](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/digitaltwins)
2126

2227
- `.\setup.ps1`
2328

2429
### Generate the ARM template
2530

26-
The ARM template [test-resources.json](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/digitaltwins/test-resources.json) is generated from the [test-resources.bicep](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/digitaltwins/test-resources_needs_fixing.bicep) file by running the following script
31+
The ARM template [test-resources.json](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/digitaltwins/test-resources.json) is generated from the [test-resources.bicep](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/digitaltwins/test-resources.bicep) file by running the following script
2732

2833
- `.\generateArmTemplate.ps1`
2934

sdk/digitaltwins/test-resources_needs_fixing.bicep renamed to sdk/digitaltwins/test-resources.bicep

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,13 @@
1-
param testApplicationOid string {
2-
metadata: {
3-
description: 'The client OID to grant access to test resources.'
4-
}
5-
}
1+
@description('The client OID to grant access to test resources.')
2+
param testApplicationOid string
63

7-
param baseName string {
8-
default : resourceGroup().name
9-
minLength: 6
10-
maxLength: 50
11-
metadata: {
12-
description: 'The base resource name.'
13-
}
14-
}
4+
@minLength(6)
5+
@maxLength(50)
6+
@description('The base resource name.')
7+
param baseName string = resourceGroup().name
158

16-
param location string {
17-
default: resourceGroup().location
18-
metadata: {
19-
description: 'The location of the resource. By default, this is the same as the resource group.'
20-
}
21-
}
9+
@description('The location of the resource. By default, this is the same as the resource group.')
10+
param location string = resourceGroup().location
2211

2312
var rbacOwnerRoleDefinitionId = '/subscriptions/${subscription().subscriptionId}/providers/Microsoft.Authorization/roleDefinitions/8e3af657-a8ff-443c-a75c-2fe8c4bcb635'
2413
var adtOwnerRoleDefinitionId = '/subscriptions/${subscription().subscriptionId}/providers/Microsoft.Authorization/roleDefinitions/bcd981a7-7f74-457b-83e1-cceb9e632ffe'
@@ -66,7 +55,6 @@ resource eventHubNamespace 'Microsoft.EventHub/namespaces@2018-01-01-preview' =
6655

6756
resource eventHubNamespaceEventHub 'Microsoft.EventHub/namespaces/eventhubs@2017-04-01' = {
6857
name: '${eventHubNamespace.name}/${baseName}'
69-
location: location
7058
properties: {
7159
messageRetentionInDays: 7
7260
partitionCount: 4
@@ -76,7 +64,6 @@ resource eventHubNamespaceEventHub 'Microsoft.EventHub/namespaces/eventhubs@2017
7664

7765
resource eventHubNamespaceAuthRules 'Microsoft.EventHub/namespaces/AuthorizationRules@2017-04-01' = {
7866
name: '${eventHubNamespace.name}/RootManageSharedAccessKey'
79-
location: location
8067
properties: {
8168
rights: [
8269
'Listen'
@@ -88,7 +75,6 @@ resource eventHubNamespaceAuthRules 'Microsoft.EventHub/namespaces/Authorization
8875

8976
resource eventHubNamespaceEventHubAuthRules 'Microsoft.EventHub/namespaces/eventhubs/authorizationRules@2017-04-01' = {
9077
name: '${eventHubNamespaceEventHub.name}/owner'
91-
location: location
9278
properties: {
9379
rights: [
9480
'Listen'
@@ -107,4 +93,4 @@ resource digitaltwinEndpoints 'Microsoft.DigitalTwins/digitalTwinsInstances/endp
10793
}
10894
}
10995

110-
output DIGITALTWINS_URL string = 'https://${digitaltwin.properties.hostName}'
96+
output DIGITALTWINS_URL string = 'https://${digitaltwin.properties.hostName}'

sdk/digitaltwins/test-resources.json

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
{
22
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
33
"contentVersion": "1.0.0.0",
4+
"metadata": {
5+
"_generator": {
6+
"name": "bicep",
7+
"version": "0.4.63.48766",
8+
"templateHash": "14469093771711807520"
9+
}
10+
},
411
"parameters": {
512
"testApplicationOid": {
613
"type": "string",
@@ -10,19 +17,19 @@
1017
},
1118
"baseName": {
1219
"type": "string",
13-
"minLength": 6,
14-
"maxLength": 50,
20+
"defaultValue": "[resourceGroup().name]",
1521
"metadata": {
1622
"description": "The base resource name."
1723
},
18-
"defaultValue": "[resourceGroup().name]"
24+
"maxLength": 50,
25+
"minLength": 6
1926
},
2027
"location": {
2128
"type": "string",
29+
"defaultValue": "[resourceGroup().location]",
2230
"metadata": {
2331
"description": "The location of the resource. By default, this is the same as the resource group."
24-
},
25-
"defaultValue": "[resourceGroup().location]"
32+
}
2633
}
2734
},
2835
"functions": [],
@@ -83,7 +90,6 @@
8390
"type": "Microsoft.EventHub/namespaces/eventhubs",
8491
"apiVersion": "2017-04-01",
8592
"name": "[format('{0}/{1}', parameters('baseName'), parameters('baseName'))]",
86-
"location": "[parameters('location')]",
8793
"properties": {
8894
"messageRetentionInDays": 7,
8995
"partitionCount": 4,
@@ -94,10 +100,9 @@
94100
]
95101
},
96102
{
97-
"type": "Microsoft.EventHub/namespaces/AuthorizationRules",
103+
"type": "Microsoft.EventHub/namespaces/authorizationRules",
98104
"apiVersion": "2017-04-01",
99105
"name": "[format('{0}/RootManageSharedAccessKey', parameters('baseName'))]",
100-
"location": "[parameters('location')]",
101106
"properties": {
102107
"rights": [
103108
"Listen",
@@ -113,7 +118,6 @@
113118
"type": "Microsoft.EventHub/namespaces/eventhubs/authorizationRules",
114119
"apiVersion": "2017-04-01",
115120
"name": "[format('{0}/owner', format('{0}/{1}', parameters('baseName'), parameters('baseName')))]",
116-
"location": "[parameters('location')]",
117121
"properties": {
118122
"rights": [
119123
"Listen",

sdk/timeseriesinsights/Azure.IoT.TimeSeriesInsights/tests/prerequisites/prerequisite readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
### Install Bicep
1717

1818
- Install using the instructions in [bicep](https://github.com/Azure/bicep/blob/main/docs/installing.md)
19+
- Note that to deploy Bicep files, use Bicep CLI version 0.3.1 or later. To check your Bicep CLI version, run:
20+
21+
```bash
22+
bicep --version
23+
```
1924

2025
### Generate the ARM template
2126

Lines changed: 41 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,52 @@
1-
param iotHubName string {
2-
metadata: {
3-
description: 'The name of the source IoT hub.'
4-
}
5-
default: az.resourceGroup().name
6-
}
1+
@description('The name of the source IoT hub.')
2+
param iotHubName string = az.resourceGroup().name
73

8-
param testApplicationOid string {
9-
metadata: {
10-
description: 'The client OID to grant access to test resources.'
11-
}
12-
}
4+
@description('The client OID to grant access to test resources.')
5+
param testApplicationOid string
136

14-
param region string {
15-
metadata: {
16-
description: 'The region of the resource. By default, this is the same as the resource group.'
17-
}
18-
default: az.resourceGroup().location
19-
}
7+
@description('The region of the resource. By default, this is the same as the resource group.')
8+
param region string = az.resourceGroup().location
209

21-
param environmentName string {
22-
metadata: {
23-
description: 'Name of the environment. The name cannot include: \'<\', \'>\', \'%\', \'&\', \':\', \'\\\', \'?\', \'/\' and any control characters. All other characters are allowed.'
24-
}
25-
maxLength: 90
26-
default: concat(az.resourceGroup().name, '-TSI')
27-
}
10+
@maxLength(90)
11+
@description('Name of the environment. The name cannot include: \'<\', \'>\', \'%\', \'&\', \':\', \'\\\', \'?\', \'/\' and any control characters. All other characters are allowed.')
12+
param environmentName string = '${az.resourceGroup().name}-TSI'
2813

29-
param consumerGroupName string {
30-
metadata: {
31-
description: 'The name of the consumer group that the Time Series Insights service will use to read the data from the event hub. NOTE: To avoid resource contention, this consumer group must be dedicated to the Time Series Insights service and not shared with other readers.'
32-
}
33-
default: concat(environmentName, 'CG')
34-
}
14+
@description('The name of the consumer group that the Time Series Insights service will use to read the data from the event hub. NOTE: To avoid resource contention, this consumer group must be dedicated to the Time Series Insights service and not shared with other readers.')
15+
param consumerGroupName string = '${environmentName}CG'
3516

36-
param environmentTimeSeriesIdProperties array {
37-
metadata: {
38-
description: 'Time Series ID acts as a partition key for your data and as a primary key for your time series model. It is important that you specify the appropriate Time Series Property ID during environment creation, since you cannot change it later. Note that the Property ID is case sensitive. You can use 1-3 keys: one is required, but up to three can be used to create a composite.'
17+
@maxLength(3)
18+
@description('Time Series ID acts as a partition key for your data and as a primary key for your time series model. It is important that you specify the appropriate Time Series Property ID during environment creation, since you cannot change it later. Note that the Property ID is case sensitive. You can use 1-3 keys: one is required, but up to three can be used to create a composite.')
19+
param environmentTimeSeriesIdProperties array = [
20+
{
21+
'name': 'building'
22+
'type': 'string'
3923
}
40-
maxLength: 3
41-
default: [
42-
{
43-
'name': 'building'
44-
'type': 'string'
45-
}
46-
{
47-
'name': 'floor'
48-
'type': 'string'
49-
}
50-
{
51-
'name': 'room'
52-
'type': 'string'
53-
}
54-
]
55-
}
56-
57-
param eventSourceName string {
58-
metadata: {
59-
description: 'Name of the event source child resource. The name cannot include: \'<\', \'>\', \'%\', \'&\', \':\', \'\\\', \'?\', \'/\' and any control characters. All other characters are allowed.'
24+
{
25+
'name': 'floor'
26+
'type': 'string'
6027
}
61-
maxLength: 90
62-
default: concat(environmentName, 'EventSourceName')
63-
}
64-
65-
param resourceGroup string {
66-
metadata: {
67-
description: 'If you have an existing IotHub provide the name here. Defaults to the same resource group as the TSI environnment.'
28+
{
29+
'name': 'room'
30+
'type': 'string'
6831
}
69-
default: az.resourceGroup().name
70-
}
32+
]
7133

72-
param eventSourceTimestampPropertyName string {
73-
metadata: {
74-
description: 'The event property that will be used as the event source\'s timestamp. If a value is not specified for timestampPropertyName, or if null or empty-string is specified, the event creation time will be used.'
75-
}
76-
maxLength: 90
77-
default: concat(eventSourceName, 'TimestampPropertyName')
78-
}
34+
@maxLength(90)
35+
@description('Name of the event source child resource. The name cannot include: \'<\', \'>\', \'%\', \'&\', \':\', \'\\\', \'?\', \'/\' and any control characters. All other characters are allowed.')
36+
param eventSourceName string = '${environmentName}EventSourceName'
7937

80-
param eventSourceKeyName string {
81-
metadata: {
82-
description: 'The name of the shared access key that the Time Series Insights service will use to connect to the event hub.'
83-
}
84-
default: 'service'
85-
}
38+
@description('If you have an existing IotHub provide the name here. Defaults to the same resource group as the TSI environnment.')
39+
param resourceGroup string = az.resourceGroup().name
40+
41+
@maxLength(90)
42+
@description('The event property that will be used as the event source\'s timestamp. If a value is not specified for timestampPropertyName, or if null or empty-string is specified, the event creation time will be used.')
43+
param eventSourceTimestampPropertyName string = '${eventSourceName}TimestampPropertyName'
44+
45+
@description('The name of the shared access key that the Time Series Insights service will use to connect to the event hub.')
46+
param eventSourceKeyName string = 'service'
8647

8748
var rbacOwnerRoleDefinitionId = '/subscriptions/${subscription().subscriptionId}/providers/Microsoft.Authorization/roleDefinitions/8e3af657-a8ff-443c-a75c-2fe8c4bcb635'
88-
var storageAccountName = concat('tsi', uniqueString(az.resourceGroup().id))
49+
var storageAccountName = 'tsi${uniqueString(az.resourceGroup().id)}'
8950
var eventSourceResourceId = resourceId(resourceGroup, 'Microsoft.Devices/IotHubs', iotHubName)
9051

9152
resource roleAssignment 'Microsoft.Authorization/roleAssignments@2018-09-01-preview' = {
@@ -107,13 +68,10 @@ resource iotHub 'Microsoft.Devices/IotHubs@2020-03-01' = {
10768
}
10869

10970
resource consumerGroup 'Microsoft.Devices/IotHubs/eventHubEndpoints/ConsumerGroups@2020-03-01' = {
110-
name: concat(iotHubName, '/events/', consumerGroupName)
71+
name: '${iotHubName}/events/${consumerGroupName}'
11172
dependsOn: [
11273
iotHub
11374
]
114-
properties: {
115-
mode: 'Complete'
116-
}
11775
}
11876

11977
resource environment 'Microsoft.TimeSeriesInsights/environments@2018-08-15-preview' = {
@@ -137,7 +95,7 @@ resource environment 'Microsoft.TimeSeriesInsights/environments@2018-08-15-previ
13795
}
13896

13997
resource eventSource 'Microsoft.TimeSeriesInsights/environments/eventsources@2018-08-15-preview' = {
140-
name: concat(environmentName, '/', eventSourceName)
98+
name: '${environmentName}/${eventSourceName}'
14199
location: region
142100
kind: 'Microsoft.IoTHub'
143101
dependsOn: [
@@ -156,7 +114,7 @@ resource eventSource 'Microsoft.TimeSeriesInsights/environments/eventsources@201
156114
}
157115

158116
resource accesspolicy 'Microsoft.TimeSeriesInsights/environments/accesspolicies@2018-08-15-preview' = {
159-
name: concat(environmentName, '/', 'contributorAccessPolicy0')
117+
name: '${environmentName}/contributorAccessPolicy0'
160118
dependsOn: [
161119
environment
162120
]
@@ -181,4 +139,4 @@ resource storageaccount 'Microsoft.Storage/storageAccounts@2018-11-01' = {
181139
var hubKeysId = resourceId('Microsoft.Devices/IotHubs/Iothubkeys', iotHubName, 'iothubowner')
182140

183141
output TIMESERIESINSIGHTS_URL string = '${environment.properties.dataAccessFqdn}'
184-
output IOTHUB_CONNECTION_STRING string = 'HostName=${iotHubName}.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=${listkeys(hubKeysId, '2019-11-04').primaryKey}'
142+
output IOTHUB_CONNECTION_STRING string = 'HostName=${iotHubName}.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=${listkeys(hubKeysId, '2019-11-04').primaryKey}'

0 commit comments

Comments
 (0)