Skip to content

Commit

Permalink
Merge branch 'Azure:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
hundredacres authored Jul 9, 2024
2 parents f589c3b + 50518ce commit 7c9743f
Show file tree
Hide file tree
Showing 49 changed files with 2,207 additions and 114 deletions.
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"microsoft-dciborow.align-bicep",
"ms-azuretools.vscode-bicep",
"ms-vsliveshare.vsliveshare",
"ms-vscode.azure-account",
"ms-vscode-remote.remote-containers",
"zokugun.explicit-folding",
"GitHub.copilot-labs"
Expand Down
93 changes: 84 additions & 9 deletions avm/res/app/job/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,86 @@ The following section provides usage examples for the module, which were used to
>**Note**: To reference the module, please use the following syntax `br/public:avm/res/app/job:<version>`.
- [Using only defaults](#example-1-using-only-defaults)
- [Using large parameter set](#example-2-using-large-parameter-set)
- [WAF-aligned](#example-3-waf-aligned)
- [Using a consumption plan](#example-1-using-a-consumption-plan)
- [Using only defaults](#example-2-using-only-defaults)
- [Using large parameter set](#example-3-using-large-parameter-set)
- [WAF-aligned](#example-4-waf-aligned)

### Example 1: _Using only defaults_
### Example 1: _Using a consumption plan_

This instance deploys the module to a Container Apps Environment with a consumption plan.


<details>

<summary>via Bicep module</summary>

```bicep
module job 'br/public:avm/res/app/job:<version>' = {
name: 'jobDeployment'
params: {
// Required parameters
containers: [
{
image: 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest'
name: 'simple-hello-world-container'
}
]
environmentResourceId: '<environmentResourceId>'
name: 'ajcon001'
triggerType: 'Manual'
// Non-required parameters
location: '<location>'
manualTriggerConfig: {}
}
}
```

</details>
<p>

<details>

<summary>via JSON Parameter file</summary>

```json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
// Required parameters
"containers": {
"value": [
{
"image": "mcr.microsoft.com/azuredocs/containerapps-helloworld:latest",
"name": "simple-hello-world-container"
}
]
},
"environmentResourceId": {
"value": "<environmentResourceId>"
},
"name": {
"value": "ajcon001"
},
"triggerType": {
"value": "Manual"
},
// Non-required parameters
"location": {
"value": "<location>"
},
"manualTriggerConfig": {
"value": {}
}
}
}
```

</details>
<p>

### Example 2: _Using only defaults_

This instance deploys the module with the minimum set of required parameters.

Expand Down Expand Up @@ -113,7 +188,7 @@ module job 'br/public:avm/res/app/job:<version>' = {
</details>
<p>

### Example 2: _Using large parameter set_
### Example 3: _Using large parameter set_

This instance deploys the module with most of its features enabled.

Expand Down Expand Up @@ -451,7 +526,7 @@ module job 'br/public:avm/res/app/job:<version>' = {
</details>
<p>

### Example 3: _WAF-aligned_
### Example 4: _WAF-aligned_

This instance deploys the module in alignment with the best-practices of the Azure Well-Architected Framework.

Expand Down Expand Up @@ -621,7 +696,7 @@ module job 'br/public:avm/res/app/job:<version>' = {
| [`secrets`](#parameter-secrets) | array | The secrets of the Container App. |
| [`tags`](#parameter-tags) | object | Tags of the resource. |
| [`volumes`](#parameter-volumes) | array | List of volume definitions for the Container App. |
| [`workloadProfileName`](#parameter-workloadprofilename) | string | The name of the workload profile to use. |
| [`workloadProfileName`](#parameter-workloadprofilename) | string | The name of the workload profile to use. Leave empty to use a consumption based profile. |

### Parameter: `containers`

Expand Down Expand Up @@ -1767,6 +1842,7 @@ The secrets of the Container App.
keyVaultUrl: 'https://myvault${environment().suffixes.keyvaultDns}/secrets/mysecret'
}
{
// You can do this, but you shouldn't. Use a secret reference instead.
name: 'mysecret'
value: 'mysecretvalue'
}
Expand Down Expand Up @@ -1928,11 +2004,10 @@ Name of the Container App secret from which to pull the secret value.

### Parameter: `workloadProfileName`

The name of the workload profile to use.
The name of the workload profile to use. Leave empty to use a consumption based profile.

- Required: No
- Type: string
- Default: `'Consumption'`


## Outputs
Expand Down
6 changes: 4 additions & 2 deletions avm/res/app/job/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ param manualTriggerConfig manualTriggerConfigType?
@description('Optional. The maximum number of times a replica can be retried.')
param replicaRetryLimit int = 0

@description('Optional. The name of the workload profile to use.')
param workloadProfileName string = 'Consumption'
@description('Optional. The name of the workload profile to use. Leave empty to use a consumption based profile.')
param workloadProfileName string?

@description('Optional. The secrets of the Container App.')
@metadata({
Expand All @@ -104,6 +104,7 @@ param workloadProfileName string = 'Consumption'
keyVaultUrl: 'https://myvault${environment().suffixes.keyvaultDns}/secrets/mysecret'
}
{
// You can do this, but you shouldn't. Use a secret reference instead.
name: 'mysecret'
value: 'mysecretvalue'
}
Expand All @@ -114,6 +115,7 @@ param workloadProfileName string = 'Consumption'
]
'''
})
#disable-next-line secure-secrets-in-params // @secure() is specified in UDT
param secrets secretType[]?

@description('Optional. List of volume definitions for the Container App.')
Expand Down
8 changes: 4 additions & 4 deletions avm/res/app/job/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"_generator": {
"name": "bicep",
"version": "0.28.1.47646",
"templateHash": "785827336085494592"
"templateHash": "2845806145425627201"
},
"name": "Container App Jobs",
"description": "This module deploys a Container App Job.",
Expand Down Expand Up @@ -886,9 +886,9 @@
},
"workloadProfileName": {
"type": "string",
"defaultValue": "Consumption",
"nullable": true,
"metadata": {
"description": "Optional. The name of the workload profile to use."
"description": "Optional. The name of the workload profile to use. Leave empty to use a consumption based profile."
}
},
"secrets": {
Expand All @@ -898,7 +898,7 @@
},
"nullable": true,
"metadata": {
"example": " [\n {\n name: 'mysecret'\n identity: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myManagedIdentity'\n keyVaultUrl: 'https://myvault${environment().suffixes.keyvaultDns}/secrets/mysecret'\n }\n {\n name: 'mysecret'\n identity: 'system'\n keyVaultUrl: 'https://myvault${environment().suffixes.keyvaultDns}/secrets/mysecret'\n }\n {\n name: 'mysecret'\n value: 'mysecretvalue'\n }\n {\n name: 'connection-string'\n value: listKeys('/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount', '2023-04-01').keys[0].value\n }\n ]\n ",
"example": " [\n {\n name: 'mysecret'\n identity: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myManagedIdentity'\n keyVaultUrl: 'https://myvault${environment().suffixes.keyvaultDns}/secrets/mysecret'\n }\n {\n name: 'mysecret'\n identity: 'system'\n keyVaultUrl: 'https://myvault${environment().suffixes.keyvaultDns}/secrets/mysecret'\n }\n {\n // You can do this, but you shouldn't. Use a secret reference instead.\n name: 'mysecret'\n value: 'mysecretvalue'\n }\n {\n name: 'connection-string'\n value: listKeys('/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount', '2023-04-01').keys[0].value\n }\n ]\n ",
"description": "Optional. The secrets of the Container App."
}
},
Expand Down
16 changes: 16 additions & 0 deletions avm/res/app/job/tests/e2e/consumptionPlan/dependencies.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@description('Required. The location to deploy resources to.')
param location string = resourceGroup().location

@description('Required. The name of the Managed Environment to create.')
param managedEnvironmentName string

resource managedEnvironment 'Microsoft.App/managedEnvironments@2024-03-01' = {
name: managedEnvironmentName
location: location
properties: {
zoneRedundant: false
}
}

@description('The resource ID of the created Managed Environment.')
output managedEnvironmentResourceId string = managedEnvironment.id
66 changes: 66 additions & 0 deletions avm/res/app/job/tests/e2e/consumptionPlan/main.test.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
targetScope = 'subscription'

metadata name = 'Using a consumption plan'
metadata description = 'This instance deploys the module to a Container Apps Environment with a consumption plan.'

// ========== //
// Parameters //
// ========== //

@description('Optional. The name of the resource group to deploy for testing purposes.')
@maxLength(90)
param resourceGroupName string = 'dep-${namePrefix}-app.job-${serviceShort}-rg'

@description('Optional. The location to deploy resources to.')
param resourceLocation string = deployment().location

@description('Optional. A short identifier for the kind of deployment. Should be kept short to not run into resource-name length-constraints.')
param serviceShort string = 'ajcon'

@description('Optional. A token to inject into the name of each resource.')
param namePrefix string = '#_namePrefix_#'

// =========== //
// Deployments //
// =========== //

// General resources
// =================
resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
name: resourceGroupName
location: resourceLocation
}

module nestedDependencies 'dependencies.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, resourceLocation)}-paramNested'
params: {
location: resourceLocation
managedEnvironmentName: 'dep-${namePrefix}-menv-${serviceShort}'
}
}

// ============== //
// Test Execution //
// ============== //

@batchSize(1)
module testDeployment '../../../main.bicep' = [
for iteration in ['init', 'idem']: {
scope: resourceGroup
name: '${uniqueString(deployment().name, resourceLocation)}-test-${serviceShort}-${iteration}'
params: {
name: '${namePrefix}${serviceShort}001'
environmentResourceId: nestedDependencies.outputs.managedEnvironmentResourceId
location: resourceLocation
triggerType: 'Manual'
manualTriggerConfig: {}
containers: [
{
name: 'simple-hello-world-container'
image: 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest'
}
]
}
}
]
8 changes: 5 additions & 3 deletions avm/res/app/job/tests/e2e/defaults/dependencies.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ param location string = resourceGroup().location
@description('Required. The name of the Managed Environment to create.')
param managedEnvironmentName string

resource managedEnvironment 'Microsoft.App/managedEnvironments@2023-05-01' = {
resource managedEnvironment 'Microsoft.App/managedEnvironments@2024-03-01' = {
name: managedEnvironmentName
location: location
properties: {
workloadProfiles: [
{
workloadProfileType: 'Consumption'
name: 'Consumption'
workloadProfileType: 'D4'
name: 'WorkloadProfile'
minimumCount: 1
maximumCount: 3
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion avm/res/app/job/tests/e2e/max/dependencies.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ param workloadProfileName string
@description('Required. The name of the storage account to create.')
param storageAccountName string

resource managedEnvironment 'Microsoft.App/managedEnvironments@2023-05-01' = {
resource managedEnvironment 'Microsoft.App/managedEnvironments@2024-03-01' = {
name: managedEnvironmentName
location: location
properties: {
Expand Down
2 changes: 1 addition & 1 deletion avm/res/app/job/tests/e2e/waf-aligned/dependencies.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ param managedIdentityName string
@description('Required. The name of the workload profile to create.')
param workloadProfileName string

resource managedEnvironment 'Microsoft.App/managedEnvironments@2023-05-01' = {
resource managedEnvironment 'Microsoft.App/managedEnvironments@2024-03-01' = {
name: managedEnvironmentName
location: location
properties: {
Expand Down
4 changes: 2 additions & 2 deletions avm/res/app/job/version.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://aka.ms/bicep-registry-module-version-file-schema#",
"version": "0.2",
"version": "0.3",
"pathFilters": [
"./main.json"
]
}
}
Loading

0 comments on commit 7c9743f

Please sign in to comment.