From 087d52b4782326aa8d98e106d0ccd106df325d1a Mon Sep 17 00:00:00 2001 From: JPEasier Date: Fri, 2 Sep 2022 16:29:41 +0200 Subject: [PATCH 1/4] change containers param --- .../containerGroups/.test/parameters.json | 34 ++++++-- .../containerGroups/deploy.bicep | 43 ++-------- .../containerGroups/readme.md | 80 ++++++++++++++----- 3 files changed, 94 insertions(+), 63 deletions(-) diff --git a/modules/Microsoft.ContainerInstance/containerGroups/.test/parameters.json b/modules/Microsoft.ContainerInstance/containerGroups/.test/parameters.json index cdbb1078cd..40452be673 100644 --- a/modules/Microsoft.ContainerInstance/containerGroups/.test/parameters.json +++ b/modules/Microsoft.ContainerInstance/containerGroups/.test/parameters.json @@ -8,13 +8,35 @@ "lock": { "value": "CanNotDelete" }, - "containerName": { - "value": "<>-az-aci-x-001" - }, - "image": { - "value": "mcr.microsoft.com/azuredocs/aci-helloworld" + "containers": { + "value": [ + { + "name": "<>-az-aci-x-001", + "properties": { + "command": [], + "image": "mcr.microsoft.com/azuredocs/aci-helloworld", + "ports": [ + { + "protocol": "Tcp", + "port": "8080" + }, + { + "protocol": "Tcp", + "port": "9000" + } + ], + "resources": { + "requests": { + "cpu": 2, + "memoryInGB": 2 + } + }, + "environmentVariables": [] + } + } + ] }, - "ports": { + "groupPorts": { "value": [ { "protocol": "Tcp", diff --git a/modules/Microsoft.ContainerInstance/containerGroups/deploy.bicep b/modules/Microsoft.ContainerInstance/containerGroups/deploy.bicep index 457484992c..420268a81d 100644 --- a/modules/Microsoft.ContainerInstance/containerGroups/deploy.bicep +++ b/modules/Microsoft.ContainerInstance/containerGroups/deploy.bicep @@ -1,25 +1,11 @@ @description('Required. Name for the container group.') param name string -@description('Required. Name for the container.') -param containername string - -@description('Required. Name of the image.') -param image string +@description('Required. The containers and their respective config within the container group.') +param containers array @description('Optional. Port to open on the container and the public IP address.') -param ports array = [ - { - protocol: 'TCP' - port: '443' - } -] - -@description('Optional. The number of CPU cores to allocate to the container.') -param cpuCores int = 2 - -@description('Optional. The amount of memory to allocate to the container in gigabytes.') -param memoryInGB int = 2 +param groupPorts array = [] @description('Optional. The operating system type required by the containers in the container group. - Windows or Linux.') param osType string = 'Linux' @@ -33,9 +19,6 @@ param ipAddressType string = 'Public' @description('Optional. The image registry credentials by which the container group is created from.') param imageRegistryCredentials array = [] -@description('Optional. Environment variables of the container group.') -param environmentVariables array = [] - @description('Optional. Location for all Resources.') param location string = resourceGroup().location @@ -84,29 +67,13 @@ resource containergroup 'Microsoft.ContainerInstance/containerGroups@2021-10-01' identity: identity tags: tags properties: { - containers: [ - { - name: containername - properties: { - command: [] - image: image - ports: ports - resources: { - requests: { - cpu: cpuCores - memoryInGB: memoryInGB - } - } - environmentVariables: environmentVariables - } - } - ] + containers: containers imageRegistryCredentials: imageRegistryCredentials restartPolicy: restartPolicy osType: osType ipAddress: { type: ipAddressType - ports: ports + ports: groupPorts } } } diff --git a/modules/Microsoft.ContainerInstance/containerGroups/readme.md b/modules/Microsoft.ContainerInstance/containerGroups/readme.md index 3059fba8ea..fe371c9f90 100644 --- a/modules/Microsoft.ContainerInstance/containerGroups/readme.md +++ b/modules/Microsoft.ContainerInstance/containerGroups/readme.md @@ -24,23 +24,19 @@ The top-level resource in Azure Container Instances is the container group. A co **Required parameters** | Parameter Name | Type | Description | | :-- | :-- | :-- | -| `containername` | string | Name for the container. | -| `image` | string | Name of the image. | +| `containers` | array | The containers and their respective config within the container group. | | `name` | string | Name for the container group. | **Optional parameters** | Parameter Name | Type | Default Value | Allowed Values | Description | | :-- | :-- | :-- | :-- | :-- | -| `cpuCores` | int | `2` | | The number of CPU cores to allocate to the container. | | `enableDefaultTelemetry` | bool | `True` | | Enable telemetry via the Customer Usage Attribution ID (GUID). | -| `environmentVariables` | array | `[]` | | Environment variables of the container group. | +| `groupPorts` | array | `[]` | | Port to open on the container and the public IP address. | | `imageRegistryCredentials` | array | `[]` | | The image registry credentials by which the container group is created from. | | `ipAddressType` | string | `'Public'` | | Specifies if the IP is exposed to the public internet or private VNET. - Public or Private. | | `location` | string | `[resourceGroup().location]` | | Location for all Resources. | | `lock` | string | `''` | `['', CanNotDelete, ReadOnly]` | Specify the type of lock. | -| `memoryInGB` | int | `2` | | The amount of memory to allocate to the container in gigabytes. | | `osType` | string | `'Linux'` | | The operating system type required by the containers in the container group. - Windows or Linux. | -| `ports` | array | `[System.Collections.Hashtable]` | | Port to open on the container and the public IP address. | | `restartPolicy` | string | `'Always'` | | Restart policy for all containers within the container group. - Always: Always restart. OnFailure: Restart on failure. Never: Never restart. - Always, OnFailure, Never. | | `systemAssignedIdentity` | bool | `False` | | Enables system assigned managed identity on the resource. | | `tags` | object | `{object}` | | Tags of the resource. | @@ -190,12 +186,35 @@ module containerGroups './Microsoft.ContainerInstance/containerGroups/deploy.bic name: '${uniqueString(deployment().name)}-ContainerGroups' params: { // Required parameters - containerName: '<>-az-aci-x-001' - image: 'mcr.microsoft.com/azuredocs/aci-helloworld' + containers: [ + { + name: '<>-az-aci-x-001' + properties: { + command: [] + environmentVariables: [] + image: 'mcr.microsoft.com/azuredocs/aci-helloworld' + ports: [ + { + port: '8080' + protocol: 'Tcp' + } + { + port: '9000' + protocol: 'Tcp' + } + ] + resources: { + requests: { + cpu: 2 + memoryInGB: 2 + } + } + } + } + ] name: '<>-az-acg-x-001' // Non-required parameters - lock: 'CanNotDelete' - ports: [ + groupPorts: [ { port: '80' protocol: 'Tcp' @@ -205,6 +224,7 @@ module containerGroups './Microsoft.ContainerInstance/containerGroups/deploy.bic protocol: 'Tcp' } ] + lock: 'CanNotDelete' systemAssignedIdentity: true userAssignedIdentities: { '/subscriptions/<>/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-<>-az-msi-x-001': {} @@ -226,20 +246,39 @@ module containerGroups './Microsoft.ContainerInstance/containerGroups/deploy.bic "contentVersion": "1.0.0.0", "parameters": { // Required parameters - "containerName": { - "value": "<>-az-aci-x-001" - }, - "image": { - "value": "mcr.microsoft.com/azuredocs/aci-helloworld" + "containers": { + "value": [ + { + "name": "<>-az-aci-x-001", + "properties": { + "command": [], + "environmentVariables": [], + "image": "mcr.microsoft.com/azuredocs/aci-helloworld", + "ports": [ + { + "port": "8080", + "protocol": "Tcp" + }, + { + "port": "9000", + "protocol": "Tcp" + } + ], + "resources": { + "requests": { + "cpu": 2, + "memoryInGB": 2 + } + } + } + } + ] }, "name": { "value": "<>-az-acg-x-001" }, // Non-required parameters - "lock": { - "value": "CanNotDelete" - }, - "ports": { + "groupPorts": { "value": [ { "port": "80", @@ -251,6 +290,9 @@ module containerGroups './Microsoft.ContainerInstance/containerGroups/deploy.bic } ] }, + "lock": { + "value": "CanNotDelete" + }, "systemAssignedIdentity": { "value": true }, From 867ed262b3fd8d1d7be6997115067b5fd374db61 Mon Sep 17 00:00:00 2001 From: JPEasier Date: Fri, 2 Sep 2022 16:42:10 +0200 Subject: [PATCH 2/4] parameter update --- .../containerGroups/.test/parameters.json | 22 ++++++++-- .../containerGroups/readme.md | 42 ++++++++++++++++--- 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/modules/Microsoft.ContainerInstance/containerGroups/.test/parameters.json b/modules/Microsoft.ContainerInstance/containerGroups/.test/parameters.json index 40452be673..1faa3a77ea 100644 --- a/modules/Microsoft.ContainerInstance/containerGroups/.test/parameters.json +++ b/modules/Microsoft.ContainerInstance/containerGroups/.test/parameters.json @@ -18,11 +18,27 @@ "ports": [ { "protocol": "Tcp", - "port": "8080" - }, + "port": "80" + } + ], + "resources": { + "requests": { + "cpu": 2, + "memoryInGB": 2 + } + }, + "environmentVariables": [] + } + }, + { + "name": "<>-az-aci-x-002", + "properties": { + "command": [], + "image": "mcr.microsoft.com/azuredocs/aci-helloworld", + "ports": [ { "protocol": "Tcp", - "port": "9000" + "port": "443" } ], "resources": { diff --git a/modules/Microsoft.ContainerInstance/containerGroups/readme.md b/modules/Microsoft.ContainerInstance/containerGroups/readme.md index fe371c9f90..bee05e9e9b 100644 --- a/modules/Microsoft.ContainerInstance/containerGroups/readme.md +++ b/modules/Microsoft.ContainerInstance/containerGroups/readme.md @@ -195,11 +195,27 @@ module containerGroups './Microsoft.ContainerInstance/containerGroups/deploy.bic image: 'mcr.microsoft.com/azuredocs/aci-helloworld' ports: [ { - port: '8080' + port: '80' protocol: 'Tcp' } + ] + resources: { + requests: { + cpu: 2 + memoryInGB: 2 + } + } + } + } + { + name: '<>-az-aci-x-002' + properties: { + command: [] + environmentVariables: [] + image: 'mcr.microsoft.com/azuredocs/aci-helloworld' + ports: [ { - port: '9000' + port: '443' protocol: 'Tcp' } ] @@ -256,11 +272,27 @@ module containerGroups './Microsoft.ContainerInstance/containerGroups/deploy.bic "image": "mcr.microsoft.com/azuredocs/aci-helloworld", "ports": [ { - "port": "8080", + "port": "80", "protocol": "Tcp" - }, + } + ], + "resources": { + "requests": { + "cpu": 2, + "memoryInGB": 2 + } + } + } + }, + { + "name": "<>-az-aci-x-002", + "properties": { + "command": [], + "environmentVariables": [], + "image": "mcr.microsoft.com/azuredocs/aci-helloworld", + "ports": [ { - "port": "9000", + "port": "443", "protocol": "Tcp" } ], From 36084f117ac7761798531a6876751f26b9951ee3 Mon Sep 17 00:00:00 2001 From: JPEasier Date: Fri, 2 Sep 2022 17:05:10 +0200 Subject: [PATCH 3/4] update readme --- .../containerGroups/.test/min.parameters.json | 60 +++++++ .../containerGroups/.test/parameters.json | 12 +- .../containerGroups/deploy.bicep | 6 +- .../containerGroups/readme.md | 165 +++++++++++++++++- 4 files changed, 232 insertions(+), 11 deletions(-) create mode 100644 modules/Microsoft.ContainerInstance/containerGroups/.test/min.parameters.json diff --git a/modules/Microsoft.ContainerInstance/containerGroups/.test/min.parameters.json b/modules/Microsoft.ContainerInstance/containerGroups/.test/min.parameters.json new file mode 100644 index 0000000000..7240bf0494 --- /dev/null +++ b/modules/Microsoft.ContainerInstance/containerGroups/.test/min.parameters.json @@ -0,0 +1,60 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "name": { + "value": "<>-az-acg-x-001" + }, + "lock": { + "value": "CanNotDelete" + }, + "containers": { + "value": [ + { + "name": "<>-az-aci-x-001", + "properties": { + "command": [], + "image": "mcr.microsoft.com/azuredocs/aci-helloworld", + "ports": [ + { + "protocol": "Tcp", + "port": "80" + }, + { + "protocol": "Tcp", + "port": "443" + } + ], + "resources": { + "requests": { + "cpu": 2, + "memoryInGB": 2 + } + }, + "environmentVariables": [] + } + } + ] + }, + "ipAddressPorts": { + "value": [ + { + "protocol": "Tcp", + "port": "80" + }, + { + "protocol": "Tcp", + "port": "443" + } + ] + }, + "systemAssignedIdentity": { + "value": true + }, + "userAssignedIdentities": { + "value": { + "/subscriptions/<>/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-<>-az-msi-x-001": {} + } + } + } +} diff --git a/modules/Microsoft.ContainerInstance/containerGroups/.test/parameters.json b/modules/Microsoft.ContainerInstance/containerGroups/.test/parameters.json index 1faa3a77ea..037d647af4 100644 --- a/modules/Microsoft.ContainerInstance/containerGroups/.test/parameters.json +++ b/modules/Microsoft.ContainerInstance/containerGroups/.test/parameters.json @@ -19,6 +19,10 @@ { "protocol": "Tcp", "port": "80" + }, + { + "protocol": "Tcp", + "port": "443" } ], "resources": { @@ -38,7 +42,7 @@ "ports": [ { "protocol": "Tcp", - "port": "443" + "port": "8080" } ], "resources": { @@ -52,7 +56,7 @@ } ] }, - "groupPorts": { + "ipAddressPorts": { "value": [ { "protocol": "Tcp", @@ -61,6 +65,10 @@ { "protocol": "Tcp", "port": "443" + }, + { + "protocol": "Tcp", + "port": "8080" } ] }, diff --git a/modules/Microsoft.ContainerInstance/containerGroups/deploy.bicep b/modules/Microsoft.ContainerInstance/containerGroups/deploy.bicep index 420268a81d..247586756a 100644 --- a/modules/Microsoft.ContainerInstance/containerGroups/deploy.bicep +++ b/modules/Microsoft.ContainerInstance/containerGroups/deploy.bicep @@ -4,8 +4,8 @@ param name string @description('Required. The containers and their respective config within the container group.') param containers array -@description('Optional. Port to open on the container and the public IP address.') -param groupPorts array = [] +@description('Conditional. Ports to open on the public IP address. Must include all ports assigned on container level.') +param ipAddressPorts array = [] @description('Optional. The operating system type required by the containers in the container group. - Windows or Linux.') param osType string = 'Linux' @@ -73,7 +73,7 @@ resource containergroup 'Microsoft.ContainerInstance/containerGroups@2021-10-01' osType: osType ipAddress: { type: ipAddressType - ports: groupPorts + ports: ipAddressPorts } } } diff --git a/modules/Microsoft.ContainerInstance/containerGroups/readme.md b/modules/Microsoft.ContainerInstance/containerGroups/readme.md index bee05e9e9b..b24042b1b2 100644 --- a/modules/Microsoft.ContainerInstance/containerGroups/readme.md +++ b/modules/Microsoft.ContainerInstance/containerGroups/readme.md @@ -27,11 +27,15 @@ The top-level resource in Azure Container Instances is the container group. A co | `containers` | array | The containers and their respective config within the container group. | | `name` | string | Name for the container group. | +**Conditional parameters** +| Parameter Name | Type | Description | +| :-- | :-- | :-- | +| `ipAddressPorts` | array | Ports to open on the public IP address. Must include all ports assigned on container level. | + **Optional parameters** | Parameter Name | Type | Default Value | Allowed Values | Description | | :-- | :-- | :-- | :-- | :-- | | `enableDefaultTelemetry` | bool | `True` | | Enable telemetry via the Customer Usage Attribution ID (GUID). | -| `groupPorts` | array | `[]` | | Port to open on the container and the public IP address. | | `imageRegistryCredentials` | array | `[]` | | The image registry credentials by which the container group is created from. | | `ipAddressType` | string | `'Public'` | | Specifies if the IP is exposed to the public internet or private VNET. - Public or Private. | | `location` | string | `[resourceGroup().location]` | | Location for all Resources. | @@ -175,7 +179,7 @@ The following module usage examples are retrieved from the content of the files >**Note**: The name of each example is based on the name of the file from which it is taken. >**Note**: Each example lists all the required parameters first, followed by the rest - each in alphabetical order. -

Example 1: Parameters

+

Example 1: Min

@@ -198,6 +202,10 @@ module containerGroups './Microsoft.ContainerInstance/containerGroups/deploy.bic port: '80' protocol: 'Tcp' } + { + port: '443' + protocol: 'Tcp' + } ] resources: { requests: { @@ -207,13 +215,126 @@ module containerGroups './Microsoft.ContainerInstance/containerGroups/deploy.bic } } } + ] + name: '<>-az-acg-x-001' + // Non-required parameters + ipAddressPorts: [ { - name: '<>-az-aci-x-002' + port: '80' + protocol: 'Tcp' + } + { + port: '443' + protocol: 'Tcp' + } + ] + lock: 'CanNotDelete' + systemAssignedIdentity: true + userAssignedIdentities: { + '/subscriptions/<>/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-<>-az-msi-x-001': {} + } + } +} +``` + +
+

+ +

+ +via JSON Parameter file + +```json +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + // Required parameters + "containers": { + "value": [ + { + "name": "<>-az-aci-x-001", + "properties": { + "command": [], + "environmentVariables": [], + "image": "mcr.microsoft.com/azuredocs/aci-helloworld", + "ports": [ + { + "port": "80", + "protocol": "Tcp" + }, + { + "port": "443", + "protocol": "Tcp" + } + ], + "resources": { + "requests": { + "cpu": 2, + "memoryInGB": 2 + } + } + } + } + ] + }, + "name": { + "value": "<>-az-acg-x-001" + }, + // Non-required parameters + "ipAddressPorts": { + "value": [ + { + "port": "80", + "protocol": "Tcp" + }, + { + "port": "443", + "protocol": "Tcp" + } + ] + }, + "lock": { + "value": "CanNotDelete" + }, + "systemAssignedIdentity": { + "value": true + }, + "userAssignedIdentities": { + "value": { + "/subscriptions/<>/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-<>-az-msi-x-001": {} + } + } + } +} +``` + +
+

+ +

Example 2: Parameters

+ +
+ +via Bicep module + +```bicep +module containerGroups './Microsoft.ContainerInstance/containerGroups/deploy.bicep' = { + name: '${uniqueString(deployment().name)}-ContainerGroups' + params: { + // Required parameters + containers: [ + { + name: '<>-az-aci-x-001' properties: { command: [] environmentVariables: [] image: 'mcr.microsoft.com/azuredocs/aci-helloworld' ports: [ + { + port: '80' + protocol: 'Tcp' + } { port: '443' protocol: 'Tcp' @@ -227,10 +348,30 @@ module containerGroups './Microsoft.ContainerInstance/containerGroups/deploy.bic } } } + { + name: '<>-az-aci-x-002' + properties: { + command: [] + environmentVariables: [] + image: 'mcr.microsoft.com/azuredocs/aci-helloworld' + ports: [ + { + port: '8080' + protocol: 'Tcp' + } + ] + resources: { + requests: { + cpu: 2 + memoryInGB: 2 + } + } + } + } ] name: '<>-az-acg-x-001' // Non-required parameters - groupPorts: [ + ipAddressPorts: [ { port: '80' protocol: 'Tcp' @@ -239,6 +380,10 @@ module containerGroups './Microsoft.ContainerInstance/containerGroups/deploy.bic port: '443' protocol: 'Tcp' } + { + port: '8080' + protocol: 'Tcp' + } ] lock: 'CanNotDelete' systemAssignedIdentity: true @@ -274,6 +419,10 @@ module containerGroups './Microsoft.ContainerInstance/containerGroups/deploy.bic { "port": "80", "protocol": "Tcp" + }, + { + "port": "443", + "protocol": "Tcp" } ], "resources": { @@ -292,7 +441,7 @@ module containerGroups './Microsoft.ContainerInstance/containerGroups/deploy.bic "image": "mcr.microsoft.com/azuredocs/aci-helloworld", "ports": [ { - "port": "443", + "port": "8080", "protocol": "Tcp" } ], @@ -310,7 +459,7 @@ module containerGroups './Microsoft.ContainerInstance/containerGroups/deploy.bic "value": "<>-az-acg-x-001" }, // Non-required parameters - "groupPorts": { + "ipAddressPorts": { "value": [ { "port": "80", @@ -319,6 +468,10 @@ module containerGroups './Microsoft.ContainerInstance/containerGroups/deploy.bic { "port": "443", "protocol": "Tcp" + }, + { + "port": "8080", + "protocol": "Tcp" } ] }, From 4c4b50cb622599488a2d17b8b879ee864312641e Mon Sep 17 00:00:00 2001 From: JPEasier Date: Fri, 2 Sep 2022 17:16:27 +0200 Subject: [PATCH 4/4] set param to optional --- .../containerGroups/deploy.bicep | 2 +- .../Microsoft.ContainerInstance/containerGroups/readme.md | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/Microsoft.ContainerInstance/containerGroups/deploy.bicep b/modules/Microsoft.ContainerInstance/containerGroups/deploy.bicep index 247586756a..9e561416ff 100644 --- a/modules/Microsoft.ContainerInstance/containerGroups/deploy.bicep +++ b/modules/Microsoft.ContainerInstance/containerGroups/deploy.bicep @@ -4,7 +4,7 @@ param name string @description('Required. The containers and their respective config within the container group.') param containers array -@description('Conditional. Ports to open on the public IP address. Must include all ports assigned on container level.') +@description('Optional. Ports to open on the public IP address. Must include all ports assigned on container level.') param ipAddressPorts array = [] @description('Optional. The operating system type required by the containers in the container group. - Windows or Linux.') diff --git a/modules/Microsoft.ContainerInstance/containerGroups/readme.md b/modules/Microsoft.ContainerInstance/containerGroups/readme.md index b24042b1b2..87cfb8f1a4 100644 --- a/modules/Microsoft.ContainerInstance/containerGroups/readme.md +++ b/modules/Microsoft.ContainerInstance/containerGroups/readme.md @@ -27,16 +27,12 @@ The top-level resource in Azure Container Instances is the container group. A co | `containers` | array | The containers and their respective config within the container group. | | `name` | string | Name for the container group. | -**Conditional parameters** -| Parameter Name | Type | Description | -| :-- | :-- | :-- | -| `ipAddressPorts` | array | Ports to open on the public IP address. Must include all ports assigned on container level. | - **Optional parameters** | Parameter Name | Type | Default Value | Allowed Values | Description | | :-- | :-- | :-- | :-- | :-- | | `enableDefaultTelemetry` | bool | `True` | | Enable telemetry via the Customer Usage Attribution ID (GUID). | | `imageRegistryCredentials` | array | `[]` | | The image registry credentials by which the container group is created from. | +| `ipAddressPorts` | array | `[]` | | Ports to open on the public IP address. Must include all ports assigned on container level. | | `ipAddressType` | string | `'Public'` | | Specifies if the IP is exposed to the public internet or private VNET. - Public or Private. | | `location` | string | `[resourceGroup().location]` | | Location for all Resources. | | `lock` | string | `''` | `['', CanNotDelete, ReadOnly]` | Specify the type of lock. |