Skip to content

Commit 19e70cf

Browse files
committed
updates related to GlobAlAzureBootcamp SG
1 parent 9aed82e commit 19e70cf

File tree

7 files changed

+298
-13
lines changed

7 files changed

+298
-13
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: dapr.io/v1alpha1
2+
kind: Component
3+
metadata:
4+
name: rabbitmq-pubsub
5+
spec:
6+
type: pubsub.rabbitmq
7+
version: v1
8+
metadata:
9+
- name: host
10+
value: 'amqp://guest:guest@rabbitmq:5672/'
11+
- name: durable
12+
value: true
13+
- name: deletedWhenUnused
14+
value: false
15+
- name: autoAck
16+
value: false
17+
- name: prefetchCount
18+
value: 50
19+
- name: reconnectWait
20+
value: 0
21+
- name: concurrencyMode
22+
# value: parallel
23+
value: single
24+
- name: exchangeKind
25+
value: fanout

config/Dapr-components/rabbitmq-dapr.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ componentType: pubsub.rabbitmq
22
version: v1
33
metadata:
44
- name: host
5-
value: 'amqp://user:tCUN6UizuwTZ@20.239.53.76:5672/'
5+
value: 'amqp://user:tCUN6UizuwTZ@20.239.73.106:5672/'
66
- name: durable
77
value: true
88
- name: deletedWhenUnused
@@ -17,4 +17,4 @@ metadata:
1717
# value: parallel
1818
value: single
1919
- name: exchangeKind
20-
value: fanout
20+
value: fanout

demo.http

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
GET https://techtalks-producer.whiteocean-6297fc2c.eastasia.azurecontainerapps.io/api/TechTalks/Generate
1+
# GET https://techtalks-producer.whiteocean-6297fc2c.eastasia.azurecontainerapps.io/api/TechTalks/Generate
2+
# ?numberOfMessages=10000
3+
4+
https://techtalks-producer.wittysmoke-dd3f636d.eastasia.azurecontainerapps.io/api/TechTalks/Generate
25
?numberOfMessages=10000
36

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
Param(
2+
[parameter(Mandatory = $false)]
3+
[string]$resourceGroupName = "azure-container-app-rg",
4+
[parameter(Mandatory = $false)]
5+
[string]$resourceGroupLocation = "eastasia",
6+
[parameter(Mandatory = $false)]
7+
[string]$environmentName = "aci-dev-env"
8+
)
9+
10+
$consumerAppSecret = az containerapp secret show `
11+
--resource-group $resourceGroupName `
12+
--name techtalks-consumer `
13+
--secret-name rabbitmq-host `
14+
--query name | ConvertFrom-Json
15+
16+
$consumerAppSecretExists = $consumerAppSecret.Length -gt 0
17+
18+
if ($consumerAppSecretExists -eq $false) {
19+
20+
Write-Host "Creating Azure Container App Secret named rabbitmq-host" -ForegroundColor Yellow
21+
22+
##Create a new secret named 'rabbitmq-host' in backend processer container app
23+
az containerapp secret set `
24+
--name techtalks-consumer `
25+
--resource-group $resourceGroupName `
26+
--secrets "rabbitmq-host=amqp://user:tCUN6UizuwTZ@20.239.73.106:5672/"
27+
28+
}
29+
else {
30+
Write-Host "Azure Container App Secret already exists" -ForegroundColor Yellow
31+
}
32+
33+
# define KEDA autoscaler
34+
35+
Write-Host "Adding KEDA scaler to Tech Talks Consumer App" -ForegroundColor Yellow
36+
37+
az containerapp update `
38+
--name techtalks-consumer `
39+
--resource-group $resourceGroupName `
40+
--min-replicas 1 `
41+
--max-replicas 25 `
42+
--scale-rule-name "rabbitmq-keda-autoscale" `
43+
--scale-rule-type "rabbitmq" `
44+
--scale-rule-auth "host=rabbitmq-host" `
45+
--scale-rule-metadata "queueName=rabbitmq-consumer-techtalks" `
46+
"mode=QueueLength" `
47+
"value=50" `
48+
"protocol=amqp" `
49+
"hostFromEnv=rabbitmq-host"
50+
51+
52+
Write-Host "Successfully Added KEDA scaler to Tech Talks Consumer App" -ForegroundColor Yellow

gabsg-2023-demo/demo-commands.ps1

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
Param(
2+
[parameter(Mandatory = $false)]
3+
[string]$resourceGroupName = "azure-container-app-rg",
4+
[parameter(Mandatory = $false)]
5+
[string]$resourceGroupLocation = "eastasia",
6+
[parameter(Mandatory = $false)]
7+
[string]$environmentName = "aci-dev-env"
8+
)
9+
10+
az containerapp create `
11+
--environment aci-dev-env `
12+
--resource-group azure-container-app-rg `
13+
--name techtalks-producer `
14+
--image ngacrregistry.azurecr.io/techtalksproducer:azurecontainerapp7.0 `
15+
--registry-server ngacrregistry.azurecr.io `
16+
--target-port 80 `
17+
--ingress 'external' `
18+
--enable-dapr `
19+
--dapr-app-id rabbitmq-producer `
20+
--dapr-app-port 80 `
21+
--min-replicas 1 `
22+
--max-replicas 3
23+
24+
az containerapp create `
25+
--environment aci-dev-env `
26+
--resource-group azure-container-app-rg `
27+
--name techtalks-consumer `
28+
--image ngacrregistry.azurecr.io/techtalksconsumer:azurecontainerapp7.0 `
29+
--registry-server ngacrregistry.azurecr.io `
30+
--target-port 80 `
31+
--ingress 'internal' `
32+
--enable-dapr `
33+
--dapr-app-id rabbitmq-consumer `
34+
--dapr-app-port 80 `
35+
--min-replicas 1
36+
37+
# Reset consumer replicas to 1, used to showcase initial state of the app
38+
az containerapp update `
39+
--name techtalks-consumer `
40+
--resource-group azure-container-app-rg `
41+
--min-replicas 1 `
42+
--max-replicas 1
43+
44+
45+
# Remove Dapr component, used to reset Dapr in case of any config changes to Pubsub components
46+
az containerapp env dapr-component remove `
47+
-g azure-container-app-rg `
48+
--dapr-component-name rabbitmq-pubsub `
49+
--name aci-dev-env
50+
51+
# Create Dapr component
52+
53+
az containerapp env dapr-component set `
54+
--name aci-dev-env `
55+
--resource-group azure-container-app-rg `
56+
--dapr-component-name rabbitmq-pubsub `
57+
--yaml ../config/Dapr-components/rabbitmq-dapr.yaml
58+
59+
# Delete TechTalks Consumer app
60+
# sometimes it doesn't work from commandline, in that case delete from the Portal
61+
# az containerapp delete `
62+
# --name techtalks-consumer `
63+
# --resource-group azure-container-app-rg `
64+
# --yes
65+
66+
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
Param(
2+
[parameter(Mandatory = $false)]
3+
[string]$subscriptionName = "Microsoft Azure Sponsorship",
4+
[parameter(Mandatory = $false)]
5+
[string]$resourceGroupName = "azure-container-app-rg",
6+
[parameter(Mandatory = $false)]
7+
[string]$resourceGroupLocation = "eastasia",
8+
[parameter(Mandatory = $false)]
9+
[string]$environmentName = "aci-dev-env"
10+
)
11+
12+
# Set Azure subscription name
13+
Write-Host "Setting Azure subscription to $subscriptionName" -ForegroundColor Yellow
14+
az account set --subscription=$subscriptionName
15+
16+
$aksRgExists = az group exists --name $resourceGroupName
17+
18+
Write-Host "$resourceGroupName exists : $aksRgExists"
19+
20+
if ($aksRgExists -eq $false) {
21+
22+
# Create resource group name
23+
Write-Host "Creating resource group $resourceGroupName in region $resourceGroupLocation" -ForegroundColor Yellow
24+
az group create `
25+
--name=$resourceGroupName `
26+
--location=$resourceGroupLocation `
27+
--output=jsonc
28+
}
29+
30+
$apsEnv = az containerapp env show `
31+
--name $environmentName `
32+
--resource-group $resourceGroupName `
33+
--query name | ConvertFrom-Json
34+
35+
$apsEnvExists = $apsEnv.Length -gt 0
36+
37+
if ($apsEnvExists -eq $false) {
38+
39+
# Create Azure Container App environment
40+
Write-Host "Creating Azure Container App environment $environmentName" -ForegroundColor Yellow
41+
42+
az containerapp env create `
43+
--name $environmentName `
44+
--resource-group $resourceGroupName `
45+
--location $resourceGroupLocation `
46+
--output=jsonc
47+
48+
Write-Host "Successfully created Azure Container App environment named : $environmentName " -ForegroundColor Yellow
49+
}
50+
else {
51+
Write-Host "Azure Container App environment named : $environmentName already exists" -ForegroundColor Yellow
52+
}
53+
54+
$daprComponent = az containerapp env dapr-component show `
55+
--name $environmentName `
56+
--resource-group $resourceGroupName `
57+
--dapr-component-name rabbitmq-pubsub `
58+
--query name | ConvertFrom-Json
59+
60+
$daprComponentExists = $daprComponent.Length -gt 0
61+
62+
if ($daprComponentExists -eq $false) {
63+
#Setup Pub Sub Dapr component
64+
Write-Host "Creating Dapr Pubsub component " -ForegroundColor Yellow
65+
66+
az containerapp env dapr-component set `
67+
--name $environmentName `
68+
--resource-group $resourceGroupName `
69+
--dapr-component-name rabbitmq-pubsub `
70+
--yaml ../config/Dapr-components/rabbitmq-dapr.yaml
71+
72+
Write-Host "Successfully created Dapr Pubsub component " -ForegroundColor Yellow
73+
74+
}
75+
else {
76+
Write-Host "Dapr Pubsub component already exists" -ForegroundColor Yellow
77+
}
78+
79+
$producerApp = az containerapp show `
80+
--resource-group $resourceGroupName `
81+
--name techtalks-producer `
82+
--query name | ConvertFrom-Json
83+
84+
$producerAppExists = $producerApp.Length -gt 0
85+
86+
if ($producerAppExists -eq $false) {
87+
88+
# Create Azure Container App for TechTalks Producer application
89+
Write-Host "Creating Azure Container App for Producer " -ForegroundColor Yellow
90+
91+
az containerapp create `
92+
--environment $environmentName `
93+
--resource-group $resourceGroupName `
94+
--name techtalks-producer `
95+
--image ngacrregistry.azurecr.io/techtalksproducer:azurecontainerapp7.0 `
96+
--registry-server ngacrregistry.azurecr.io `
97+
--target-port 80 `
98+
--ingress 'external' `
99+
--enable-dapr `
100+
--dapr-app-id rabbitmq-producer `
101+
--dapr-app-port 80 `
102+
--min-replicas 1 `
103+
--max-replicas 3
104+
105+
Write-Host "Successfully created Azure Container App for Producer " -ForegroundColor Yellow
106+
}
107+
else {
108+
Write-Host "Azure Container App for Producer already exists" -ForegroundColor Yellow
109+
}
110+
111+
$consumerApp = az containerapp show `
112+
--resource-group $resourceGroupName `
113+
--name techtalks-consumer `
114+
--query name | ConvertFrom-Json
115+
116+
$consumerAppExists = $consumerApp.Length -gt 0
117+
118+
if ($consumerAppExists -eq $false) {
119+
# Create Azure Container App for TechTalks Producer application
120+
Write-Host "Creating Azure Container App for Consumer " -ForegroundColor Yellow
121+
122+
az containerapp create `
123+
--environment $environmentName `
124+
--resource-group $resourceGroupName `
125+
--name techtalks-consumer `
126+
--image ngacrregistry.azurecr.io/techtalksconsumer:azurecontainerapp7.0 `
127+
--registry-server ngacrregistry.azurecr.io `
128+
--target-port 80 `
129+
--ingress 'internal' `
130+
--enable-dapr `
131+
--dapr-app-id rabbitmq-consumer `
132+
--dapr-app-port 80 `
133+
--min-replicas 1
134+
135+
Write-Host "Successfully created Azure Container App for Consumer " -ForegroundColor Yellow
136+
}
137+
else {
138+
Write-Host "Azure Container App for Consumer already exists" -ForegroundColor Yellow
139+
}

powershell/setup-tech-talks-container-app.ps1

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,16 @@ az containerapp update `
212212
# --dapr-component-name rabbitmq-pubsub `
213213
# --name aci-dev-env
214214

215-
# az vm create `
216-
# --resource-group azure-container-app-rg `
217-
# --name rabbitmq-new `
218-
# --admin-username azureuser `
219-
# --generate-ssh-keys `
220-
# --image bitnami:rabbitmq:rabbitmq:latest `
221-
# --plan-name rabbitmq `
222-
# --plan-product rabbitmq `
223-
# --plan-publisher bitnami `
224-
# --public-ip-sku Standard
215+
az vm create `
216+
--resource-group azure-container-app-rg `
217+
--name rabbitmq `
218+
--admin-username azureuser `
219+
--generate-ssh-keys `
220+
--image bitnami:rabbitmq:rabbitmq:latest `
221+
--plan-name rabbitmq `
222+
--plan-product rabbitmq `
223+
--plan-publisher bitnami `
224+
--public-ip-sku Standard
225225

226226
# delete resource group $resourceGroupName
227227

0 commit comments

Comments
 (0)