Skip to content

Commit

Permalink
feat: DevOpsPool - Fixed parameter requirement for images (#3401)
Browse files Browse the repository at this point in the history
## Description

- Fixed the requirement for the image parameter to allow the usage of a
compute gallery image

Example from portal deployment


![image](https://github.com/user-attachments/assets/d6a304eb-bc27-4d71-8411-cd62eeb42e2b)

Exported JSON
```json
"images": [
    {
        "resourceId": "/Subscriptions/b765c5e5-ae60-4724-9b59-36fbcf56795b/Providers/Microsoft.Compute/Locations/westeurope/publishers/microsoftwindowsdesktop/artifacttypes/vmimage/offers/windows-11/skus/win11-22h2-pro/versions/latest",
        "buffer": "*"
    },
    {
        "wellKnownImageName": "ubuntu-22.04/latest",
        "buffer": "*",
        "aliases": [
            "ubuntu-22.04"
        ]
    },
    {
        "resourceId": "/subscriptions/b765c5e5-ae60-4724-9b59-36fbcf56795b/resourceGroups/rg-ado-agents/providers/Microsoft.Compute/galleries/galaib/images/sid-linux/versions/latest",
        "buffer": "*"
    }
]
```

## Pipeline Reference

<!-- Insert your Pipeline Status Badge below -->

| Pipeline |
| -------- |
|
[![avm.res.dev-ops-infrastructure.pool](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.dev-ops-infrastructure.pool.yml/badge.svg?branch=users%2Falsehr%2FdevopsPoolImageFix&event=workflow_dispatch)](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.dev-ops-infrastructure.pool.yml)
|

## Type of Change

<!-- Use the checkboxes [x] on the options that are relevant. -->

- [ ] Update to CI Environment or utilities (Non-module affecting
changes)
- [ ] Azure Verified Module updates:
- [x] Bugfix containing backwards-compatible bug fixes, and I have NOT
bumped the MAJOR or MINOR version in `version.json`:
- [ ] Someone has opened a bug report issue, and I have included "Closes
#{bug_report_issue_number}" in the PR description.
- [ ] The bug was found by the module author, and no one has opened an
issue to report it yet.
- [ ] Feature update backwards compatible feature updates, and I have
bumped the MINOR version in `version.json`.
- [ ] Breaking changes and I have bumped the MAJOR version in
`version.json`.
  - [ ] Update to documentation
  • Loading branch information
AlexanderSehr authored Oct 11, 2024
1 parent fdfb2e6 commit 0ef32a0
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 57 deletions.
24 changes: 12 additions & 12 deletions avm/res/dev-ops-infrastructure/pool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -810,25 +810,32 @@ The VM images of the machines in the pool.
- Required: Yes
- Type: array

**Required parameters**
**Conditional parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`wellKnownImageName`](#parameter-imageswellknownimagename) | string | The image to use from a well-known set of images made available to customers. |
| [`resourceId`](#parameter-imagesresourceid) | string | The specific resource id of the marketplace or compute gallery image. Required if `wellKnownImageName` is not set. |
| [`wellKnownImageName`](#parameter-imageswellknownimagename) | string | The image to use from a well-known set of images made available to customers. Required if `resourceId` is not set. |

**Optional parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`aliases`](#parameter-imagesaliases) | array | List of aliases to reference the image by. |
| [`buffer`](#parameter-imagesbuffer) | string | The percentage of the buffer to be allocated to this image. |
| [`resourceId`](#parameter-imagesresourceid) | string | The resource id of the image. |

### Parameter: `images.resourceId`

The specific resource id of the marketplace or compute gallery image. Required if `wellKnownImageName` is not set.

- Required: No
- Type: string

### Parameter: `images.wellKnownImageName`

The image to use from a well-known set of images made available to customers.
The image to use from a well-known set of images made available to customers. Required if `resourceId` is not set.

- Required: Yes
- Required: No
- Type: string

### Parameter: `images.aliases`
Expand All @@ -845,13 +852,6 @@ The percentage of the buffer to be allocated to this image.
- Required: No
- Type: string

### Parameter: `images.resourceId`

The resource id of the image.

- Required: No
- Type: string

### Parameter: `name`

Name of the pool. It needs to be globally unique.
Expand Down
24 changes: 19 additions & 5 deletions avm/res/dev-ops-infrastructure/pool/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ param fabricProfileSkuName string
param concurrency int

@description('Required. The VM images of the machines in the pool.')
param images imageType
param images imageType[]

@description('Optional. The geo-location where the resource lives.')
param location string = resourceGroup().location
Expand Down Expand Up @@ -235,6 +235,7 @@ output location string = managedDevOpsPool.location
@description('The principal ID of the system assigned identity.')
output systemAssignedMIPrincipalId string? = managedDevOpsPool.?identity.?principalId

@export()
type osProfileType = {
@description('Required. The logon type of the machine.')
logonType: ('Interactive' | 'Service')
Expand All @@ -252,6 +253,7 @@ type osProfileType = {
}?
}

@export()
type storageProfileType = {
@description('Optional. The Azure SKU name of the machines in the pool.')
osDiskStorageAccountType: ('Premium' | 'StandardSSD' | 'Standard')?
Expand All @@ -272,20 +274,22 @@ type storageProfileType = {
}[]?
}?

@export()
type imageType = {
@description('Optional. List of aliases to reference the image by.')
aliases: string[]?

@description('Optional. The percentage of the buffer to be allocated to this image.')
buffer: string?

@description('Required. The image to use from a well-known set of images made available to customers.')
wellKnownImageName: string
@description('Conditional. The image to use from a well-known set of images made available to customers. Required if `resourceId` is not set.')
wellKnownImageName: string?

@description('Optional. The resource id of the image.')
@description('Conditional. The specific resource id of the marketplace or compute gallery image. Required if `wellKnownImageName` is not set.')
resourceId: string?
}[]
}

@export()
type organizationProfileType = {
@description('Required. Azure DevOps organization profile.')
kind: 'AzureDevOps'
Expand Down Expand Up @@ -317,6 +321,7 @@ type organizationProfileType = {
}[]
}

@export()
type dataDiskType = {
@description('Optional. The type of caching to be enabled for the data disks. The default value for caching is readwrite. For information about the caching options see: https://blogs.msdn.microsoft.com/windowsazurestorage/2012/06/27/exploring-windows-azure-drives-disks-and-images/.')
caching: ('None' | 'ReadOnly' | 'ReadWrite')?
Expand All @@ -331,6 +336,7 @@ type dataDiskType = {
storageAccountType: ('Premium_LRS' | 'Premium_ZRS' | 'StandardSSD_LRS' | 'StandardSSD_ZRS' | 'Standard_LRS')?
}[]?

@export()
type resourcePredictionsProfileAutomaticType = {
@description('Required. The stand-by agent scheme is determined based on historical demand.')
kind: 'Automatic'
Expand All @@ -339,11 +345,13 @@ type resourcePredictionsProfileAutomaticType = {
predictionPreference: 'Balanced' | 'MostCostEffective' | 'MoreCostEffective' | 'MorePerformance' | 'BestPerformance'
}

@export()
type resourcePredictionsProfileManualType = {
@description('Required. Customer provides the stand-by agent scheme.')
kind: 'Manual'
}

@export()
type agentStatefulType = {
@description('Required. Stateful profile meaning that the machines will be returned to the pool after running a job.')
kind: 'Stateful'
Expand All @@ -362,6 +370,7 @@ type agentStatefulType = {
resourcePredictionsProfile: (resourcePredictionsProfileAutomaticType | resourcePredictionsProfileManualType)?
}

@export()
type agentStatelessType = {
@description('Required. Stateless profile meaning that the machines will be cleaned up after running a job.')
kind: 'Stateless'
Expand Down Expand Up @@ -400,8 +409,10 @@ type agentStatelessType = {
}

@discriminator('kind')
@export()
type agentProfileType = agentStatefulType | agentStatelessType

@export()
type roleAssignmentType = {
@description('Optional. The name (as GUID) of the role assignment. If not provided, a GUID will be generated.')
name: string?
Expand All @@ -428,6 +439,7 @@ type roleAssignmentType = {
delegatedManagedIdentityResourceId: string?
}[]?

@export()
type lockType = {
@description('Optional. Specify the name of lock.')
name: string?
Expand All @@ -436,6 +448,7 @@ type lockType = {
kind: ('CanNotDelete' | 'ReadOnly' | 'None')?
}?

@export()
type diagnosticSettingType = {
@description('Optional. The name of diagnostic setting.')
name: string?
Expand Down Expand Up @@ -480,6 +493,7 @@ type diagnosticSettingType = {
marketplacePartnerResourceId: string?
}[]?

@export()
type managedIdentitiesType = {
@description('Optional. Enables system assigned managed identity on the resource.')
systemAssigned: bool?
Expand Down
Loading

0 comments on commit 0ef32a0

Please sign in to comment.