-
Notifications
You must be signed in to change notification settings - Fork 0
/
deployAzureResources.sh
141 lines (126 loc) · 4.48 KB
/
deployAzureResources.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
resource_group_name="iot-analytics-poc"
location="westeurope"
# group_exits=$(az group exists --name $resource_group_name --output tsv);
# group_exits=$(echo "$group_exits" | tr -d '\r')
# echo "Create Azure resources"
# if [ $group_exits = false ]; then
# echo "Group does not exists"
# else
# echo "Group exists and will be deleted first"
# # az group delete --name $resource_group_name --yes
# fi
# az group create --name $resource_group_name --location $location
az deployment group create -f ./main.bicep -g $resource_group_name
output=$(az deployment group create -f ./main.bicep -g $resource_group_name --query "properties.outputs");
# echo "$output"
echo
iot_hub_id_output=$(echo "$output" | jq '.iothubId.value')
echo "$iot_hub_id_output"
regex_pattern="IotHubs\/([a-zA-Z0-9\-]*)"
if [[ $iot_hub_id_output =~ $regex_pattern ]]
then
iot_hub_id=${BASH_REMATCH[1]}
echo "$iot_hub_id"
else
echo "no match found"
fi
echo
storage_account_id_output=$(echo "$output" | jq '.storageId.value')
echo "$storage_account_id_output"
regex_pattern="storageAccounts\/([a-zA-Z0-9]*)"
if [[ $storage_account_id_output =~ $regex_pattern ]]
then
storage_account_id=${BASH_REMATCH[1]}
echo "$storage_account_id"
else
echo "no match found"
fi
echo
event_hub_id_output=$(echo "$output" | jq '.eventHubId.value')
echo "$event_hub_id_output"
regex_pattern="\/eventhubs\/([a-zA-Z0-9\-]*)"
if [[ $event_hub_id_output =~ $regex_pattern ]]
then
event_hub_id=${BASH_REMATCH[1]}
echo "$event_hub_id"
else
echo "no match found"
fi
echo
event_hub_namespace_id_output=$(echo "$output" | jq '.eventHubNamespaceId.value')
echo "$event_hub_namespace_id_output"
regex_pattern="\/Microsoft.EventHub\/namespaces\/([a-zA-Z0-9\-]*)"
if [[ $event_hub_namespace_id_output =~ $regex_pattern ]]
then
event_hub_namespace_id=${BASH_REMATCH[1]}
echo "$event_hub_namespace_id"
else
echo "no match found"
fi
echo
regex_pattern="\/subscriptions\/([a-f0-9\-]*)\/"
if [[ $storage_account_id_output =~ $regex_pattern ]]
then
subscription_id=${BASH_REMATCH[1]}
echo "$subscription_id"
else
echo "no match found"
fi
echo
event_hub_id_output_adedirectdigitallab=$(echo "$output" | jq '.eventHubIdAdedirectdigitallab.value')
echo "$event_hub_id_output_adedirectdigitallab"
regex_pattern="\/eventhubs\/([a-zA-Z0-9\-]*)"
if [[ $event_hub_id_output_adedirectdigitallab =~ $regex_pattern ]]
then
event_hub_id_adedirectdigitallab=${BASH_REMATCH[1]}
echo "$event_hub_id_adedirectdigitallab"
else
echo "no match found"
fi
echo
event_hub_id_output_aintestingdirect1016247=$(echo "$output" | jq '.eventHubIdAintestingdirect1016247.value')
echo "$event_hub_id_output_aintestingdirect1016247"
regex_pattern="\/eventhubs\/([a-zA-Z0-9\-]*)"
if [[ $event_hub_id_output_aintestingdirect1016247 =~ $regex_pattern ]]
then
event_hub_id_aintestingdirect1016247=${BASH_REMATCH[1]}
echo "$event_hub_id_aintestingdirect1016247"
else
echo "no match found"
fi
echo
event_hub_id_output_asaenrich2routingapp=$(echo "$output" | jq '.eventHubIdAsaenrich2routingapp.value')
echo "$event_hub_id_output_asaenrich2routingapp"
regex_pattern="\/eventhubs\/([a-zA-Z0-9\-]*)"
if [[ $event_hub_id_output_asaenrich2routingapp =~ $regex_pattern ]]
then
event_hub_id_asaenrich2routingapp=${BASH_REMATCH[1]}
echo "$event_hub_id_asaenrich2routingapp"
else
echo "no match found"
fi
echo
event_hub_id_output_iothub2asadigitallab=$(echo "$output" | jq '.eventHubIdIothub2asadigitallab.value')
echo "$event_hub_id_output_iothub2asadigitallab"
regex_pattern="\/eventhubs\/([a-zA-Z0-9\-]*)"
if [[ $event_hub_id_output_iothub2asadigitallab =~ $regex_pattern ]]
then
event_hub_id_iothub2asadigitallab=${BASH_REMATCH[1]}
echo "$event_hub_id_iothub2asadigitallab"
else
echo "no match found"
fi
echo
event_hub_id_output_iothub2asaenrichmessage=$(echo "$output" | jq '.eventHubIdIothub2asaenrichmessage.value')
echo "$event_hub_id_output_iothub2asaenrichmessage"
regex_pattern="\/eventhubs\/([a-zA-Z0-9\-]*)"
if [[ $event_hub_id_output_iothub2asaenrichmessage =~ $regex_pattern ]]
then
event_hub_id_iothub2asaenrichmessage=${BASH_REMATCH[1]}
echo "$event_hub_id_iothub2asaenrichmessage"
else
echo "no match found"
fi
echo
sh ./configureConnections.sh $resource_group_name $storage_account_id $iot_hub_id $subscription_id $event_hub_namespace_id $event_hub_id $event_hub_id_adedirectdigitallab $event_hub_id_aintestingdirect1016247 $event_hub_id_asaenrich2routingapp $event_hub_id_iothub2asadigitallab $event_hub_id_iothub2asaenrichmessage