Skip to content

Commit

Permalink
Simplify VM availability zone parameters (#1030)
Browse files Browse the repository at this point in the history
* test availabilityZone set to 0

* retest with 0 array

* change vm availabilityZone desc

* Added testing for Availability Zones

* Update param to be of range

* Revert decorator and readme to use allowed values rather than range
  • Loading branch information
Marius Storhaug committed Feb 23, 2022
1 parent 4d45b5f commit 0752ff8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"encryptionAtHost": {
"value": false
},
"availabilityZone": {
"value": 1
},
"imageReference": {
"value": {
"publisher": "Canonical",
Expand All @@ -37,7 +40,6 @@
}
}
},

"adminUsername": {
"value": "localAdminUser"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
"diskSizeGB": "128",
"managedDisk": {
"storageAccountType": "Premium_LRS"

}

}
},

"availabilityZone": {
"value": 2
},
"adminUsername": {
"value": "localAdminUser"
},
Expand Down
8 changes: 2 additions & 6 deletions arm/Microsoft.Compute/virtualMachines/deploy.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@ param proximityPlacementGroupName 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. Creates an availability zone and adds the VMs to it. Cannot be used in combination with availability set nor scale set.')
param useAvailabilityZone bool = false

@description('Optional. If set to 1, 2 or 3, the availability zone for all VMs is hardcoded to that value. If zero, then the automatic algorithm will be used to give every VM in a different zone (up to three zones). Cannot be used in combination with availability set nor scale set.')
@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([
0
1
Expand Down Expand Up @@ -350,7 +347,7 @@ resource virtualMachine 'Microsoft.Compute/virtualMachines@2021-07-01' = {
location: location
identity: identity
tags: tags
zones: useAvailabilityZone ? array(availabilityZone) : null
zones: availabilityZone != 0 ? array(availabilityZone) : null
plan: !empty(plan) ? plan : null
properties: {
hardwareProfile: {
Expand All @@ -363,7 +360,6 @@ resource virtualMachine 'Microsoft.Compute/virtualMachines@2021-07-01' = {
secureBootEnabled: secureBootEnabled
vTpmEnabled: vTpmEnabled
} : null

}
storageProfile: {
imageReference: imageReference
Expand Down
28 changes: 13 additions & 15 deletions arm/Microsoft.Compute/virtualMachines/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This module deploys one Virtual Machine with one or multiple nics and optionally
| `adminUsername` | secureString | | | Required. Administrator username |
| `allowExtensionOperations` | bool | `True` | | Optional. 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 | | | Optional. Resource name of an availability set. Cannot be used in combination with availability zone nor scale set. |
| `availabilityZone` | int | | `[0, 1, 2, 3]` | Optional. If set to 1, 2 or 3, the availability zone for all VMs is hardcoded to that value. If zero, then the automatic algorithm will be used to give every VM in a different zone (up to three zones). Cannot be used in combination with availability set nor scale set. |
| `availabilityZone` | int | `0` | `[0, 1, 2, 3]` | 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. |
| `backupPolicyName` | string | `DefaultPolicy` | | Optional. 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 | | | Optional. Recovery service vault name to add VMs to backup. |
| `backupVaultResourceGroup` | string | `[resourceGroup().name]` | | Optional. Resource group of the backup recovery service vault. If not provided the current resource group name is considered by default. |
Expand All @@ -36,20 +36,19 @@ This module deploys one Virtual Machine with one or multiple nics and optionally
| `configurationProfileAssignments` | array | `[]` | | Optional. Any VM configuration profile assignments |
| `cuaId` | string | | | Optional. Customer Usage Attribution ID (GUID). This GUID must be previously registered |
| `customData` | string | | | Optional. Custom data associated to the VM, this value will be automatically converted into base64 to account for the expected VM format. |
| `dataDisks` | array | `[]` | | Optional. Specifies the data disks. For security reasons, it is recommended to specify DiskEncryptionSet into the dataDisk object. Restrictions: DiskEncryptionSet cannot be enabled if Azure Disk Encryption (guest-VM encryption using bitlocker/DM-Crypt) is enabled on your VMs.|
| `dataDisks` | array | `[]` | | Optional. Specifies the data disks. For security reasons, it is recommended to specify DiskEncryptionSet into the dataDisk object. Restrictions: DiskEncryptionSet cannot be enabled if Azure Disk Encryption (guest-VM encryption using bitlocker/DM-Crypt) is enabled on your VMs. |
| `dedicatedHostId` | string | | | Optional. Specifies resource ID about the dedicated host that the virtual machine resides in. |
| `diagnosticEventHubAuthorizationRuleId` | string | | | Optional. Resource ID of the diagnostic event hub authorization rule for the Event Hubs namespace in which the event hub should be created or streamed to. |
| `diagnosticEventHubName` | string | | | Optional. Name of the diagnostic event hub within the namespace to which logs are streamed. Without this, an event hub is created for each log category. |
| `diagnosticLogsRetentionInDays` | int | `365` | | Optional. Specifies the number of days that logs will be kept for; a value of 0 will retain data indefinitely. |
| `diagnosticStorageAccountId` | string | | | Optional. Resource ID of the diagnostic storage account. |
| `diagnosticWorkspaceId` | string | | | Optional. Resource ID of the diagnostic log analytics workspace. |
| `disablePasswordAuthentication` | bool | | | Optional. Specifies whether password authentication should be disabled. |
| `disablePasswordAuthentication` | bool | `False` | | Optional. Specifies whether password authentication should be disabled. |
| `enableAutomaticUpdates` | bool | `True` | | Optional. Indicates whether Automatic Updates is enabled for the Windows virtual machine. Default value is true. For virtual machine scale sets, this property can be updated and updates will take effect on OS reprovisioning. |
| `enableEvictionPolicy` | bool | | | Optional. Specifies the eviction policy for the low priority virtual machine. Will result in 'Deallocate' eviction policy. |
| `enableServerSideEncryption` | bool | | | Optional. Specifies if Windows VM disks should be encrypted with Server-side encryption + Customer managed Key. |
| `enableEvictionPolicy` | bool | `False` | | Optional. Specifies the eviction policy for the low priority virtual machine. Will result in 'Deallocate' eviction policy. |
| `enableServerSideEncryption` | bool | `False` | | Optional. Specifies if Windows VM disks should be encrypted with Server-side encryption + Customer managed Key. |
| `encryptionAtHost` | bool | `True` | | Optional. This property can be used by user in the request to enable or disable the Host Encryption for the virtual machine. This will enable the encryption for all the disks including Resource/Temp disk at host itself. For security reasons, it is recommended to set encryptionAtHost to True. Restrictions: Cannot be enabled if Azure Disk Encryption (guest-VM encryption using bitlocker/DM-Crypt) is enabled on your VMs. |
| `extensionAntiMalwareConfig` | object | `{object}` | | Optional. The configuration for the [Anti Malware] extension. Must at least contain the ["enabled": true] property to be executed |
| `extensionAntiMalwareConfig` | object | `{object}` | | Optional. The configuration for the [Anti Malware] extension. Must at least contain the ["enabled": true] property to be executed |
| `extensionCustomScriptConfig` | object | `{object}` | | Optional. The configuration for the [Custom Script] extension. Must at least contain the ["enabled": true] property to be executed |
| `extensionDependencyAgentConfig` | object | `{object}` | | Optional. The configuration for the [Dependency Agent] extension. Must at least contain the ["enabled": true] property to be executed |
| `extensionDiskEncryptionConfig` | object | `{object}` | | Optional. The configuration for the [Disk Encryption] extension. Must at least contain the ["enabled": true] property to be executed |
Expand All @@ -63,12 +62,12 @@ This module deploys one Virtual Machine with one or multiple nics and optionally
| `location` | string | `[resourceGroup().location]` | | Optional. Location for all resources. |
| `lock` | string | `NotSpecified` | `[CanNotDelete, NotSpecified, ReadOnly]` | Optional. Specify the type of lock. |
| `maxPriceForLowPriorityVm` | string | | | Optional. Specifies the maximum price you are willing to pay for a low priority VM/VMSS. This price is in US Dollars. |
| `monitoringWorkspaceId` | string | | | Optional. Resource ID of the monitoring log analytics workspace. Must be set when extensionMonitoringAgentConfig is set to true.|
| `monitoringWorkspaceId` | string | | | Optional. Resource ID of the monitoring log analytics workspace. Must be set when extensionMonitoringAgentConfig is set to true. |
| `name` | string | `[take(toLower(uniqueString(resourceGroup().name)), 10)]` | | Optional. The name of the virtual machine to be created. You should use a unique prefix to reduce name collisions in Active Directory. If no value is provided, a 10 character long unique string will be generated based on the Resource Group's name. |
| `nicConfigurations` | array | | | Required. Configures NICs and PIPs. |
| `nicMetricsToEnable` | array | `[AllMetrics]` | `[AllMetrics]` | Optional. The name of metrics that will be streamed. |
| `osDisk` | object | | | Required. Specifies the OS disk. For security reasons, it is recommended to specify DiskEncryptionSet into the osDisk object. Restrictions: DiskEncryptionSet cannot be enabled if Azure Disk Encryption (guest-VM encryption using bitlocker/DM-Crypt) is enabled on your VMs.|
| `osType` | string | | `[Windows, Linux]` | Required. The chosen OS type|
| `osDisk` | object | | | Required. Specifies the OS disk. For security reasons, it is recommended to specify DiskEncryptionSet into the osDisk object. Restrictions: DiskEncryptionSet cannot be enabled if Azure Disk Encryption (guest-VM encryption using bitlocker/DM-Crypt) is enabled on your VMs. |
| `osType` | string | | `[Windows, Linux]` | Required. The chosen OS type |
| `pipLogsToEnable` | array | `[DDoSProtectionNotifications, DDoSMitigationFlowLogs, DDoSMitigationReports]` | `[DDoSProtectionNotifications, DDoSMitigationFlowLogs, DDoSMitigationReports]` | Optional. The name of logs that will be streamed. |
| `pipMetricsToEnable` | array | `[AllMetrics]` | `[AllMetrics]` | Optional. The name of metrics that will be streamed. |
| `plan` | object | `{object}` | | Optional. 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. |
Expand All @@ -77,13 +76,12 @@ This module deploys one Virtual Machine with one or multiple nics and optionally
| `publicKeys` | array | `[]` | | Optional. The list of SSH public keys used to authenticate with linux based VMs |
| `roleAssignments` | array | `[]` | | Optional. 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` | | Optional. 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. |
| `securityType` | string | | `TrustedLaunch` | Optional. Specifies the SecurityType of the virtual machine. It is set as TrustedLaunch to enable UefiSettings. |
| `secureBootEnabled` | bool | `False` | | Optional. Specifies whether secure boot should be enabled on the virtual machine. This parameter is part of the UefiSettings. SecurityType should be set to TrustedLaunch to enable UefiSettings. |
| `systemAssignedIdentity` | bool | | | Optional. Enables system assigned managed identity on the resource. |
| `secureBootEnabled` | bool | `False` | | Optional. Specifies whether secure boot should be enabled on the virtual machine. This parameter is part of the UefiSettings. SecurityType should be set to TrustedLaunch to enable UefiSettings. |
| `securityType` | string | | | Optional. Specifies the SecurityType of the virtual machine. It is set as TrustedLaunch to enable UefiSettings. |
| `systemAssignedIdentity` | bool | `False` | | Optional. Enables system assigned managed identity on the resource. |
| `tags` | object | `{object}` | | Optional. Tags of the resource. |
| `timeZone` | string | | | Optional. Specifies the time zone of the virtual machine. e.g. 'Pacific Standard Time'. Possible values can be 'TimeZoneInfo.id' value from time zones returned by TimeZoneInfo.GetSystemTimeZones. |
| `ultraSSDEnabled` | bool | | | Optional. The flag that enables or disables a capability to have one or more managed data disks with UltraSSD_LRS storage account type on the VM or VMSS. Managed disks with storage account type UltraSSD_LRS can be added to a virtual machine or virtual machine scale set only if this property is enabled. |
| `useAvailabilityZone` | bool | | | Optional. Creates an availability zone and adds the VMs to it. Cannot be used in combination with availability set nor scale set. |
| `timeZone` | string | | | Optional. Specifies the time zone of the virtual machine. e.g. 'Pacific Standard Time'. Possible values can be TimeZoneInfo.id value from time zones returned by TimeZoneInfo.GetSystemTimeZones. |
| `ultraSSDEnabled` | bool | `False` | | Optional. The flag that enables or disables a capability to have one or more managed data disks with UltraSSD_LRS storage account type on the VM or VMSS. Managed disks with storage account type UltraSSD_LRS can be added to a virtual machine or virtual machine scale set only if this property is enabled. |
| `userAssignedIdentities` | object | `{object}` | | Optional. The ID(s) to assign to the resource. |
| `vmComputerNamesTransformation` | string | `none` | | Optional. Specifies whether the computer names should be transformed. The transformation is performed on all computer names. Available transformations are 'none' (Default), 'uppercase' and 'lowercase'. |
| `vmPriority` | string | `Regular` | `[Regular, Low, Spot]` | Optional. Specifies the priority for the virtual machine. |
Expand Down
2 changes: 1 addition & 1 deletion utilities/tools/Set-ModuleReadMe.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function Set-ParametersSection {
$defaultValue = ($param.defaultValue -is [array]) ? ('[{0}]' -f ($param.defaultValue -join ', ')) : (($param.defaultValue -is [hashtable]) ? '{object}' : $param.defaultValue)
$allowed = ($param.allowedValues -is [array]) ? ('[{0}]' -f ($param.allowedValues -join ', ')) : (($param.allowedValues -is [hashtable]) ? '{object}' : $param.allowedValues)
$description = $param.metadata.description
$SectionContent += ('| `{0}` | {1} | {2} | {3} | {4} |' -f $paramName, $type, (($defaultValue) ? "``$defaultValue``" : ''), (($allowed) ? "``$allowed``" : ''), $description)
$SectionContent += ('| `{0}` | {1} | {2} | {3} | {4} |' -f $paramName, $type, (![string]::IsNullOrEmpty($defaultValue) ? "``$defaultValue``" : ''), (($allowed) ? "``$allowed``" : ''), $description)
}

# Build result
Expand Down

0 comments on commit 0752ff8

Please sign in to comment.