Skip to content

Commit 27e746e

Browse files
authored
Merge pull request #293097 from craigshoemaker/aca/scale-app-code
[Container Apps] Update Scale app -> move code snippets into main repo
2 parents bd49f8b + 36b7032 commit 27e746e

6 files changed

+130
-16
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
az containerapp create \
2+
--name <CONTAINER_APP_NAME> \
3+
--resource-group <RESOURCE_GROUP> \
4+
--environment <ENVIRONMENT_NAME> \
5+
--image <CONTAINER_IMAGE_LOCATION>
6+
--min-replicas 0 \
7+
--max-replicas 5 \
8+
--secrets "connection-string-secret=<SERVICE_BUS_CONNECTION_STRING>" \
9+
--scale-rule-name azure-servicebus-queue-rule \
10+
--scale-rule-type azure-servicebus \
11+
--scale-rule-metadata "queueName=my-queue" \
12+
"namespace=service-bus-namespace" \
13+
"messageCount=5" \
14+
--scale-rule-auth "connection=connection-string-secret"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
...
2+
"rules": [
3+
{
4+
"name": "azure-servicebus-queue-rule",
5+
"custom": {
6+
"type": "azure-servicebus",
7+
"metadata": {
8+
"queueName": "my-queue",
9+
"namespace": "service-bus-namespace",
10+
"messageCount": "5"
11+
}
12+
}
13+
}
14+
]
15+
...
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
...
3+
"resources": {
4+
...
5+
"properties": {
6+
...
7+
"configuration": {
8+
...
9+
"secrets": [
10+
{
11+
"name": "connection-string-secret",
12+
"value": "<SERVICE_BUS_CONNECTION_STRING>"
13+
}
14+
]
15+
},
16+
"template": {
17+
...
18+
"scale": {
19+
"minReplicas": 0,
20+
"maxReplicas": 5,
21+
"rules": [
22+
{
23+
"name": "azure-servicebus-queue-rule",
24+
"custom": {
25+
"type": "azure-servicebus",
26+
"metadata": {
27+
"queueName": "my-queue",
28+
"namespace": "service-bus-namespace",
29+
"messageCount": "5"
30+
},
31+
"auth": [
32+
{
33+
"secretRef": "connection-string-secret",
34+
"triggerParameter": "connection"
35+
}
36+
]
37+
}
38+
}
39+
]
40+
}
41+
}
42+
}
43+
}
44+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: my-secrets
5+
namespace: my-project
6+
type: Opaque
7+
data:
8+
connection-string-secret: <SERVICE_BUS_CONNECTION_STRING>
9+
---
10+
apiVersion: keda.sh/v1alpha1
11+
kind: TriggerAuthentication
12+
metadata:
13+
name: azure-servicebus-auth
14+
spec:
15+
secretTargetRef:
16+
- parameter: connection
17+
name: my-secrets
18+
key: connection-string-secret
19+
---
20+
apiVersion: keda.sh/v1alpha1
21+
kind: ScaledObject
22+
metadata:
23+
name: azure-servicebus-queue-rule
24+
namespace: default
25+
spec:
26+
scaleTargetRef:
27+
name: my-scale-target
28+
triggers:
29+
- type: azure-servicebus
30+
metadata:
31+
queueName: my-queue
32+
namespace: service-bus-namespace
33+
messageCount: "5"
34+
authenticationRef:
35+
name: azure-servicebus-auth
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
triggers:
2+
- type: azure-servicebus
3+
metadata:
4+
queueName: my-queue
5+
namespace: service-bus-namespace
6+
messageCount: "5"

articles/container-apps/scale-app.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -303,19 +303,19 @@ First, you define the type and metadata of the scale rule.
303303

304304
1. From the KEDA scaler specification, find the `type` value.
305305

306-
:::code language="yml" source="~/azure-docs-snippets-pr/container-apps/keda-azure-service-bus-trigger.yml" highlight="2":::
306+
:::code language="yml" source="./code/keda-azure-service-bus-trigger.json" highlight="2":::
307307

308308
1. In the ARM template, enter the scaler `type` value into the `custom.type` property of the scale rule.
309309

310-
:::code language="json" source="~/azure-docs-snippets-pr/container-apps/container-apps-azure-service-bus-rule-0.json" highlight="6":::
310+
:::code language="json" source="./code/container-apps-azure-service-bus-rule-0.json" highlight="6":::
311311

312312
1. From the KEDA scaler specification, find the `metadata` values.
313313

314-
:::code language="yml" source="~/azure-docs-snippets-pr/container-apps/keda-azure-service-bus-trigger.yml" highlight="4,5,6":::
314+
:::code language="yml" source="./code/keda-azure-service-bus-trigger.json" highlight="4,5,6":::
315315

316316
1. In the ARM template, add all metadata values to the `custom.metadata` section of the scale rule.
317317

318-
:::code language="json" source="~/azure-docs-snippets-pr/container-apps/container-apps-azure-service-bus-rule-0.json" highlight="8,9,10":::
318+
:::code language="json" source="./code/container-apps-azure-service-bus-rule-0.json" highlight="8,9,10":::
319319

320320
### Authentication
321321

@@ -331,7 +331,7 @@ KEDA scalers can use secrets in a [TriggerAuthentication](https://keda.sh/docs/l
331331

332332
1. In the `TriggerAuthentication` object, find each `secretTargetRef` and its associated secret.
333333

334-
:::code language="yml" source="~/azure-docs-snippets-pr/container-apps/keda-azure-service-bus-auth.yml" highlight="8,16,17,18":::
334+
:::code language="yml" source="./code/keda-azure-service-bus-auth.json" highlight="8,16,17,18":::
335335

336336
1. In the ARM template, for each secret:
337337

@@ -343,7 +343,7 @@ KEDA scalers can use secrets in a [TriggerAuthentication](https://keda.sh/docs/l
343343

344344
1. Set the value of the `secretRef` property to the name of the `secretTargetRef`'s `key` property.
345345

346-
:::code language="json" source="~/azure-docs-snippets-pr/container-apps/container-apps-azure-service-bus-rule-1.json" highlight="10,11,12,13,32,33,34,35":::
346+
:::code language="json" source="./code/container-apps-azure-service-bus-rule-1.json" highlight="10,11,12,13,32,33,34,35":::
347347

348348
Some scalers support metadata with the `FromEnv` suffix to reference a value in an environment variable. Container Apps looks at the first container listed in the ARM template for the environment variable.
349349

@@ -382,21 +382,21 @@ To learn more about using managed identity with scale rules, see [Managed identi
382382

383383
1. From the KEDA scaler specification, find the `type` value.
384384

385-
:::code language="yml" source="~/azure-docs-snippets-pr/container-apps/keda-azure-service-bus-trigger.yml" highlight="2":::
385+
:::code language="yml" source="./code/keda-azure-service-bus-trigger.json" highlight="2":::
386386

387387
1. In the CLI command, set the `--scale-rule-type` parameter to the specification `type` value.
388388

389-
:::code language="bash" source="~/azure-docs-snippets-pr/container-apps/container-apps-azure-service-bus-cli.bash" highlight="10":::
389+
:::code language="bash" source="./code/container-apps-azure-service-bus-cli.json" highlight="10":::
390390

391391
1. From the KEDA scaler specification, find the `metadata` values.
392392

393-
:::code language="yml" source="~/azure-docs-snippets-pr/container-apps/keda-azure-service-bus-trigger.yml" highlight="4,5,6":::
393+
:::code language="yml" source="./code/keda-azure-service-bus-trigger.json" highlight="4,5,6":::
394394

395395
1. In the CLI command, set the `--scale-rule-metadata` parameter to the metadata values.
396396

397397
You need to transform the values from a YAML format to a key/value pair for use on the command line. Separate each key/value pair with a space.
398398

399-
:::code language="bash" source="~/azure-docs-snippets-pr/container-apps/container-apps-azure-service-bus-cli.bash" highlight="11,12,13":::
399+
:::code language="bash" source="./code/container-apps-azure-service-bus-cli.json" highlight="11,12,13":::
400400

401401
### Authentication
402402

@@ -410,7 +410,7 @@ A KEDA scaler supports secrets in a [TriggerAuthentication](https://keda.sh/docs
410410

411411
1. Find the `TriggerAuthentication` object referenced by the KEDA `ScaledObject` specification. Identify each `secretTargetRef` of the `TriggerAuthentication` object.
412412

413-
:::code language="yml" source="~/azure-docs-snippets-pr/container-apps/keda-azure-service-bus-auth.yml" highlight="8,16,17,18":::
413+
:::code language="yml" source="./code/keda-azure-service-bus-auth.json" highlight="8,16,17,18":::
414414

415415
1. In your container app, create the [secrets](./manage-secrets.md) that match the `secretTargetRef` properties.
416416

@@ -420,8 +420,8 @@ A KEDA scaler supports secrets in a [TriggerAuthentication](https://keda.sh/docs
420420

421421
1. Create an authentication entry with the `--scale-rule-auth` parameter. If there are multiple entries, separate them with a space.
422422

423-
:::code language="bash" source="~/azure-docs-snippets-pr/container-apps/container-apps-azure-service-bus-cli.bash" highlight="8,14":::
424-
423+
:::code language="bash" source="./code/container-apps-azure-service-bus-cli.json" highlight="8,14":::
424+
425425
#### Using managed identity
426426

427427
Container Apps scale rules can use managed identity to authenticate with Azure services. The following command creates a container app with a user-assigned managed identity and uses it to authenticate for an Azure Queue scaler.
@@ -464,13 +464,13 @@ Replace placeholders with your values.
464464

465465
1. From the KEDA scaler specification, find the `type` value.
466466

467-
:::code language="yml" source="~/azure-docs-snippets-pr/container-apps/keda-azure-service-bus-trigger.yml" highlight="2":::
467+
:::code language="yml" source="./code/keda-azure-service-bus-trigger.json" highlight="2":::
468468

469469
1. In the *Custom rule type* box, enter the scaler `type` value.
470470

471471
1. From the KEDA scaler specification, find the `metadata` values.
472472

473-
:::code language="yml" source="~/azure-docs-snippets-pr/container-apps/keda-azure-service-bus-trigger.yml" highlight="4,5,6":::
473+
:::code language="yml" source="./code/keda-azure-service-bus-trigger.json" highlight="4,5,6":::
474474

475475
1. In the portal, find the *Metadata* section and select **Add**. Enter the name and value for each item in the KEDA `ScaledObject` specification metadata section.
476476

@@ -484,7 +484,7 @@ Container Apps scale rules support secrets-based authentication. Scale rules for
484484

485485
1. Find the `TriggerAuthentication` object referenced by the KEDA `ScaledObject` specification. Identify each `secretTargetRef` of the `TriggerAuthentication` object.
486486

487-
:::code language="yml" source="~/azure-docs-snippets-pr/container-apps/keda-azure-service-bus-auth.yml" highlight="16,17,18":::
487+
:::code language="yml" source="./code/keda-azure-service-bus-auth.json" highlight="16,17,18":::
488488

489489
1. In the *Authentication* section, select **Add** to create an entry for each KEDA `secretTargetRef` parameter.
490490

0 commit comments

Comments
 (0)