Skip to content

Commit

Permalink
[Modules] VM: Added proximityPlacementGroup test + changed param form…
Browse files Browse the repository at this point in the history
…at (#1760)

* Added prox test + changed param format

* Update to latest
  • Loading branch information
AlexanderSehr authored Aug 8, 2022
1 parent 87f95ab commit 5042c3d
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 48 deletions.
30 changes: 18 additions & 12 deletions .azuredevops/platformPipelines/platform.dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@ stages:
displayName: Locks Resource Group

- ${{ if eq( parameters.deployVhdDependencies, true) }}:
- stage: deploy_vhd
displayName: Store VHD to Storage Account
dependsOn:
- deploy_rg
variables:
templateFilePath: $(dependencyPath)/constructs/StoreVhdToStorage/deploy.bicep
jobs:
- template: /.azuredevops/pipelineTemplates/jobs.dependenciesModuleDeployment.yml
parameters:
deploymentBlocks:
- templateFilePath: $(templateFilePath)
displayName: Deploy module
- stage: deploy_vhd
displayName: Store VHD to Storage Account
dependsOn:
- deploy_rg
variables:
templateFilePath: $(dependencyPath)/constructs/StoreVhdToStorage/deploy.bicep
jobs:
- template: /.azuredevops/pipelineTemplates/jobs.dependenciesModuleDeployment.yml
parameters:
deploymentBlocks:
- templateFilePath: $(templateFilePath)
displayName: Deploy module

- stage: deploy_ppg
displayName: Deploy proximity placement group
Expand All @@ -79,6 +79,12 @@ stages:
- path: $(dependencyPath)/$(resourceType)/parameters/parameters.json
templateFilePath: $(templateFilePath)
displayName: Proximity Placement Group
- path: $(dependencyPath)/$(resourceType)/parameters/vm.parameters.json
templateFilePath: $(templateFilePath)
displayName: VM Proximity Placement Group
- path: $(dependencyPath)/$(resourceType)/parameters/vmss.parameters.json
templateFilePath: $(templateFilePath)
displayName: VMSS Proximity Placement Group

- stage: deploy_msi
displayName: Deploy user assigned identity
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/platform.dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
strategy:
fail-fast: false
matrix:
parameterFilePaths: ['parameters.json']
parameterFilePaths: ['parameters.json', 'vm.parameters.json', 'vmss.parameters.json']
steps:
- name: 'Checkout'
uses: actions/checkout@v2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@
"diagnosticEventHubName": {
"value": "adp-<<namePrefix>>-az-evh-x-001"
},
"proximityPlacementGroupResourceId": {
"value": "/subscriptions/<<subscriptionId>>/resourceGroups/validation-rg/providers/Microsoft.Compute/proximityPlacementGroups/adp-<<namePrefix>>-az-ppg-vmss-001"
},
"extensionAntiMalwareConfig": {
"value": {
"enabled": true,
Expand Down
24 changes: 4 additions & 20 deletions modules/Microsoft.Compute/virtualMachineScaleSets/deploy.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,8 @@ param roleAssignments array = []
@description('Optional. Fault Domain count for each placement group.')
param scaleSetFaultDomain int = 2

@description('Optional. Creates an proximity placement group and adds the VMs to it.')
param proximityPlacementGroupName string = ''

@description('Optional. Specifies the type of the proximity placement group.')
@allowed([
'Standard'
'Ultra'
])
param proximityPlacementGroupType string = 'Standard'
@description('Optional. Resource ID of a proximity placement group.')
param proximityPlacementGroupResourceId string = ''

@description('Required. Configures NICs and PIPs.')
param nicConfigurations array = []
Expand Down Expand Up @@ -355,24 +348,15 @@ resource defaultTelemetry 'Microsoft.Resources/deployments@2021-04-01' = if (ena
}
}

resource proximityPlacementGroup 'Microsoft.Compute/proximityPlacementGroups@2021-04-01' = if (!empty(proximityPlacementGroupName)) {
name: !empty(proximityPlacementGroupName) ? proximityPlacementGroupName : 'dummyProximityGroup'
location: location
tags: tags
properties: {
proximityPlacementGroupType: proximityPlacementGroupType
}
}

resource vmss 'Microsoft.Compute/virtualMachineScaleSets@2021-04-01' = {
name: name
location: location
tags: tags
identity: identity
zones: availabilityZones
properties: {
proximityPlacementGroup: !empty(proximityPlacementGroupName) ? {
id: az.resourceId('Microsoft.Compute/proximityPlacementGroups', proximityPlacementGroup.name)
proximityPlacementGroup: !empty(proximityPlacementGroupResourceId) ? {
id: proximityPlacementGroupResourceId
} : null
upgradePolicy: {
mode: upgradePolicyMode
Expand Down
8 changes: 5 additions & 3 deletions modules/Microsoft.Compute/virtualMachineScaleSets/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ This module deploys a virtual machine scale set.
| :-- | :-- |
| `Microsoft.Authorization/locks` | [2017-04-01](https://docs.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2017-04-01/locks) |
| `Microsoft.Authorization/roleAssignments` | [2020-10-01-preview](https://docs.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2020-10-01-preview/roleAssignments) |
| `Microsoft.Compute/proximityPlacementGroups` | [2021-04-01](https://docs.microsoft.com/en-us/azure/templates/Microsoft.Compute/2021-04-01/proximityPlacementGroups) |
| `Microsoft.Compute/virtualMachineScaleSets` | [2021-04-01](https://docs.microsoft.com/en-us/azure/templates/Microsoft.Compute/2021-04-01/virtualMachineScaleSets) |
| `Microsoft.Compute/virtualMachineScaleSets/extensions` | [2021-07-01](https://docs.microsoft.com/en-us/azure/templates/Microsoft.Compute/2021-07-01/virtualMachineScaleSets/extensions) |
| `Microsoft.Insights/diagnosticSettings` | [2021-05-01-preview](https://docs.microsoft.com/en-us/azure/templates/Microsoft.Insights/2021-05-01-preview/diagnosticSettings) |
Expand Down Expand Up @@ -87,8 +86,7 @@ The following resources are required to be able to deploy this resource.
| `pauseTimeBetweenBatches` | string | `'PT0S'` | | The wait time between completing the update for all virtual machines in one batch and starting the next batch. The time duration should be specified in ISO 8601 format. |
| `plan` | object | `{object}` | | Specifies information about the marketplace image used to create the virtual machine. This element is only used for marketplace images. Before you can use a marketplace image from an API, you must enable the image for programmatic use. |
| `provisionVMAgent` | bool | `True` | | Indicates whether virtual machine agent should be provisioned on the virtual machine. When this property is not specified in the request body, default behavior is to set it to true. This will ensure that VM Agent is installed on the VM so that extensions can be added to the VM later. |
| `proximityPlacementGroupName` | string | `''` | | Creates an proximity placement group and adds the VMs to it. |
| `proximityPlacementGroupType` | string | `'Standard'` | `[Standard, Ultra]` | Specifies the type of the proximity placement group. |
| `proximityPlacementGroupResourceId` | string | `''` | | Resource ID of a proximity placement group. |
| `publicIpDiagnosticSettingsName` | string | `[format('{0}-diagnosticSettings', parameters('name'))]` | | The name of the diagnostic setting, if deployed. |
| `publicKeys` | array | `[]` | | The list of SSH public keys used to authenticate with linux based VMs. |
| `roleAssignments` | array | `[]` | | Array of role assignment objects that contain the 'roleDefinitionIdOrName' and 'principalId' to define RBAC role assignments on this resource. In the roleDefinitionIdOrName attribute, you can provide either the display name of the role definition, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'. |
Expand Down Expand Up @@ -1595,6 +1593,7 @@ module virtualMachineScaleSets './Microsoft.Compute/virtualMachineScaleSets/depl
nicSuffix: '-nic01'
}
]
proximityPlacementGroupResourceId: '/subscriptions/<<subscriptionId>>/resourceGroups/validation-rg/providers/Microsoft.Compute/proximityPlacementGroups/adp-<<namePrefix>>-az-ppg-vmss-001'
roleAssignments: [
{
principalIds: [
Expand Down Expand Up @@ -1778,6 +1777,9 @@ module virtualMachineScaleSets './Microsoft.Compute/virtualMachineScaleSets/depl
}
]
},
"proximityPlacementGroupResourceId": {
"value": "/subscriptions/<<subscriptionId>>/resourceGroups/validation-rg/providers/Microsoft.Compute/proximityPlacementGroups/adp-<<namePrefix>>-az-ppg-vmss-001"
},
"roleAssignments": {
"value": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "0.4"
"version": "0.5"
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@
"diagnosticEventHubName": {
"value": "adp-<<namePrefix>>-az-evh-x-001"
},
"proximityPlacementGroupResourceId": {
"value": "/subscriptions/<<subscriptionId>>/resourceGroups/validation-rg/providers/Microsoft.Compute/proximityPlacementGroups/adp-<<namePrefix>>-az-ppg-vm-001"
},
"systemAssignedIdentity": {
"value": true
},
Expand Down
24 changes: 16 additions & 8 deletions modules/Microsoft.Compute/virtualMachines/deploy.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ param bootDiagnosticStorageAccountName string = ''
@description('Optional. Storage account boot diagnostic base URI.')
param bootDiagnosticStorageAccountUri string = '.blob.${environment().suffixes.storage}/'

@description('Optional. Resource name of a proximity placement group.')
param proximityPlacementGroupName string = ''
@description('Optional. Resource ID of a proximity placement group.')
param proximityPlacementGroupResourceId string = ''

@description('Optional. Resource name of an availability set. Cannot be used in combination with availability zone nor scale set.')
param availabilitySetName string = ''
@description('Optional. Resource ID of an availability set. Cannot be used in combination with availability zone nor scale set.')
param availabilitySetResourceId string = ''

@description('Optional. If set to 1, 2 or 3, the availability zone for all VMs is hardcoded to that value. If zero, then availability zones is not used. Cannot be used in combination with availability set nor scale set.')
@allowed([
Expand Down Expand Up @@ -451,12 +451,20 @@ resource vm 'Microsoft.Compute/virtualMachines@2021-07-01' = {
storageUri: !empty(bootDiagnosticStorageAccountName) ? 'https://${bootDiagnosticStorageAccountName}${bootDiagnosticStorageAccountUri}' : null
}
}
availabilitySet: !empty(availabilitySetName) ? json('{"id":"${az.resourceId('Microsoft.Compute/availabilitySets', availabilitySetName)}"}') : null
proximityPlacementGroup: !empty(proximityPlacementGroupName) ? json('{"id":"${az.resourceId('Microsoft.Compute/proximityPlacementGroups', proximityPlacementGroupName)}"}') : null
availabilitySet: !empty(availabilitySetResourceId) ? {
id: availabilitySetResourceId
} : null
proximityPlacementGroup: !empty(proximityPlacementGroupResourceId) ? {
id: proximityPlacementGroupResourceId
} : null
priority: vmPriority
evictionPolicy: enableEvictionPolicy ? 'Deallocate' : null
billingProfile: !empty(vmPriority) && !empty(maxPriceForLowPriorityVm) ? json('{"maxPrice":"${maxPriceForLowPriorityVm}"}') : null
host: !empty(dedicatedHostId) ? json('{"id":"${dedicatedHostId}"}') : null
billingProfile: !empty(vmPriority) && !empty(maxPriceForLowPriorityVm) ? {
maxPrice: maxPriceForLowPriorityVm
} : null
host: !empty(dedicatedHostId) ? {
id: dedicatedHostId
} : null
licenseType: !empty(licenseType) ? licenseType : null
}
dependsOn: [
Expand Down
8 changes: 6 additions & 2 deletions modules/Microsoft.Compute/virtualMachines/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ This module deploys one Virtual Machine with one or multiple nics and optionally
| `additionalUnattendContent` | array | `[]` | | Specifies additional base-64 encoded XML formatted information that can be included in the Unattend.xml file, which is used by Windows Setup. - AdditionalUnattendContent object. |
| `adminPassword` | secureString | `''` | | When specifying a Windows Virtual Machine, this value should be passed. |
| `allowExtensionOperations` | bool | `True` | | Specifies whether extension operations should be allowed on the virtual machine. This may only be set to False when no extensions are present on the virtual machine. |
| `availabilitySetName` | string | `''` | | Resource name of an availability set. Cannot be used in combination with availability zone nor scale set. |
| `availabilitySetResourceId` | string | `''` | | Resource ID of an availability set. Cannot be used in combination with availability zone nor scale set. |
| `availabilityZone` | int | `0` | `[0, 1, 2, 3]` | If set to 1, 2 or 3, the availability zone for all VMs is hardcoded to that value. If zero, then availability zones is not used. Cannot be used in combination with availability set nor scale set. |
| `backupPolicyName` | string | `'DefaultPolicy'` | | Backup policy the VMs should be using for backup. If not provided, it will use the DefaultPolicy from the backup recovery service vault. |
| `backupVaultName` | string | `''` | | Recovery service vault name to add VMs to backup. |
Expand Down Expand Up @@ -89,7 +89,7 @@ This module deploys one Virtual Machine with one or multiple nics and optionally
| `pipDiagnosticSettingsName` | string | `[format('{0}-diagnosticSettings', parameters('name'))]` | | The name of the PIP diagnostic setting, if deployed. |
| `plan` | object | `{object}` | | Specifies information about the marketplace image used to create the virtual machine. This element is only used for marketplace images. Before you can use a marketplace image from an API, you must enable the image for programmatic use. |
| `provisionVMAgent` | bool | `True` | | Indicates whether virtual machine agent should be provisioned on the virtual machine. When this property is not specified in the request body, default behavior is to set it to true. This will ensure that VM Agent is installed on the VM so that extensions can be added to the VM later. |
| `proximityPlacementGroupName` | string | `''` | | Resource name of a proximity placement group. |
| `proximityPlacementGroupResourceId` | string | `''` | | Resource ID of a proximity placement group. |
| `publicKeys` | array | `[]` | | The list of SSH public keys used to authenticate with linux based VMs. |
| `roleAssignments` | array | `[]` | | Array of role assignment objects that contain the 'roleDefinitionIdOrName' and 'principalId' to define RBAC role assignments on this resource. In the roleDefinitionIdOrName attribute, you can provide either the display name of the role definition, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'. |
| `sasTokenValidityLength` | string | `'PT8H'` | | SAS token validity length to use to download files from storage accounts. Usage: 'PT8H' - valid for 8 hours; 'P5D' - valid for 5 days; 'P1Y' - valid for 1 year. When not provided, the SAS token will be valid for 8 hours. |
Expand Down Expand Up @@ -2070,6 +2070,7 @@ module virtualMachines './Microsoft.Compute/virtualMachines/deploy.bicep' = {
lock: 'CanNotDelete'
monitoringWorkspaceId: '/subscriptions/<<subscriptionId>>/resourcegroups/validation-rg/providers/microsoft.operationalinsights/workspaces/adp-<<namePrefix>>-az-law-x-001'
name: '<<namePrefix>>-vm-win-01'
proximityPlacementGroupResourceId: '/subscriptions/<<subscriptionId>>/resourceGroups/validation-rg/providers/Microsoft.Compute/proximityPlacementGroups/adp-<<namePrefix>>-az-ppg-vm-001'
roleAssignments: [
{
principalIds: [
Expand Down Expand Up @@ -2311,6 +2312,9 @@ module virtualMachines './Microsoft.Compute/virtualMachines/deploy.bicep' = {
"name": {
"value": "<<namePrefix>>-vm-win-01"
},
"proximityPlacementGroupResourceId": {
"value": "/subscriptions/<<subscriptionId>>/resourceGroups/validation-rg/providers/Microsoft.Compute/proximityPlacementGroups/adp-<<namePrefix>>-az-ppg-vm-001"
},
"roleAssignments": {
"value": [
{
Expand Down
2 changes: 1 addition & 1 deletion modules/Microsoft.Compute/virtualMachines/version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "0.4"
"version": "0.5"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"value": "adp-<<namePrefix>>-az-ppg-vm-001"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"value": "adp-<<namePrefix>>-az-ppg-vmss-001"
}
}
}

0 comments on commit 5042c3d

Please sign in to comment.