-
Notifications
You must be signed in to change notification settings - Fork 437
[Modules] Updated Compute/VirtualMachineScaleSets to new dependency approach #1865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AlexanderSehr
merged 39 commits into
main
from
users/alsehr/1791_Compute_virtualMachineScaleSets
Nov 18, 2022
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
b085405
Initial setup
AlexanderSehr f63a496
Update to latest
AlexanderSehr ea358f0
Regenerated docs & expanded error output
AlexanderSehr 2ca3c6d
Updated RBAC handling
AlexanderSehr cabe189
Update to latest
AlexanderSehr d30d918
Small fix
AlexanderSehr 874b61a
Merge branch 'main' into users/alsehr/1791_Compute_virtualMachineScal…
AlexanderSehr 4dae90c
Update to latest
AlexanderSehr b5c4bf0
Update to latest
AlexanderSehr fa817a6
Update modules/Microsoft.Compute/virtualMachineScaleSets/.test/linux.…
AlexanderSehr bb2e7c0
Update modules/Microsoft.Compute/virtualMachineScaleSets/.test/linux/…
AlexanderSehr 5d8a59f
Update modules/Microsoft.Compute/virtualMachineScaleSets/.test/window…
AlexanderSehr 4cbf2d7
Update modules/Microsoft.Compute/virtualMachineScaleSets/.test/window…
AlexanderSehr ceaf41b
Update to latest
AlexanderSehr 3f6de07
Update to latest
AlexanderSehr e5fcf9b
Update to latest
AlexanderSehr 525bc62
Merged latest main
AlexanderSehr fc3513b
refreshed readme
AlexanderSehr f6b430f
Update to latest
AlexanderSehr 58fb092
Updated naming
AlexanderSehr c251674
Updated powershell version
AlexanderSehr 74008fa
Update modules/Microsoft.Compute/virtualMachineScaleSets/.test/linux.…
AlexanderSehr 47efc6f
Update modules/Microsoft.Compute/virtualMachineScaleSets/.test/linux.…
AlexanderSehr 6b2182b
Update modules/Microsoft.Compute/virtualMachineScaleSets/.test/linux/…
AlexanderSehr f8aa3f0
Update modules/Microsoft.Compute/virtualMachineScaleSets/.test/linux.…
AlexanderSehr f4afa57
Update modules/Microsoft.Compute/virtualMachineScaleSets/.test/window…
AlexanderSehr e167100
Update modules/Microsoft.Compute/virtualMachineScaleSets/.test/window…
AlexanderSehr a7f9c8c
Update modules/Microsoft.Compute/virtualMachineScaleSets/.test/window…
AlexanderSehr 8d493a3
Update modules/Microsoft.Compute/virtualMachineScaleSets/.test/linux/…
AlexanderSehr 252fbf2
Updated further AZPS versions
AlexanderSehr ed2a323
Renamed output
AlexanderSehr d669546
Removed output
AlexanderSehr 4e7701d
Removed output
AlexanderSehr f81f7a7
Merge branch 'main' into users/alsehr/1791_Compute_virtualMachineScal…
AlexanderSehr 1b8045a
Regenerated docs
AlexanderSehr 4eef1c9
Update to latest
AlexanderSehr d8e04cd
Merge branch 'main' into users/alsehr/1791_Compute_virtualMachineScal…
AlexanderSehr 6f0fd43
Regenerated docs
AlexanderSehr d1066d9
Merged latest main
AlexanderSehr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
modules/Microsoft.Compute/virtualMachineScaleSets/.test/.scripts/New-SSHKey.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| param( | ||
| [string] $SSHKeyName, | ||
| [string] $ResourceGroupName | ||
| ) | ||
|
|
||
| if (-not ($sshKey = Get-AzSshKey -ResourceGroupName $ResourceGroupName | Where-Object { $_.Name -eq $SSHKeyName })) { | ||
| Write-Verbose "No SSH key [$SSHKeyName] found in Resource Group [$ResourceGroupName]. Generating new." -Verbose | ||
| $null = ssh-keygen -f generated -N (Get-Random -Maximum 99999) | ||
| $publicKey = Get-Content 'generated.pub' -Raw | ||
| # $privateKey = cat generated | Out-String | ||
| } else { | ||
| Write-Verbose "SSH key [$SSHKeyName] found in Resource Group [$ResourceGroupName]. Returning." -Verbose | ||
| $publicKey = $sshKey.publicKey | ||
| } | ||
| # Write into Deployment Script output stream | ||
| $DeploymentScriptOutputs = @{ | ||
| # Requires conversion as the script otherwise returns an object instead of the plain public key string | ||
| publicKey = $publicKey | Out-String | ||
| } | ||
15 changes: 15 additions & 0 deletions
15
modules/Microsoft.Compute/virtualMachineScaleSets/.test/.scripts/Set-BlobContent.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| param( | ||
| [string] $StorageAccountName, | ||
| [string] $ResourceGroupName, | ||
| [string] $ContainerName, | ||
| [string] $FileName | ||
| ) | ||
|
|
||
| Write-Verbose "Create file [$FileName]" -Verbose | ||
| $file = New-Item -Value "Write-Host 'I am content'" -Path $FileName -Force | ||
|
|
||
| Write-Verbose "Getting storage account [$StorageAccountName|$ResourceGroupName] context." -Verbose | ||
| $storageAccount = Get-AzStorageAccount -ResourceGroupName $ResourceGroupName -StorageAccountName $StorageAccountName -ErrorAction 'Stop' | ||
|
|
||
| Write-Verbose 'Uploading file [$fileName]' -Verbose | ||
| Set-AzStorageBlobContent -File $file.FullName -Container $ContainerName -Context $storageAccount.Context -Force -ErrorAction 'Stop' | Out-Null |
63 changes: 0 additions & 63 deletions
63
modules/Microsoft.Compute/virtualMachineScaleSets/.test/linux.min.parameters.json
This file was deleted.
Oops, something went wrong.
84 changes: 84 additions & 0 deletions
84
modules/Microsoft.Compute/virtualMachineScaleSets/.test/linux.min/dependencies.bicep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| @description('Optional. The location to deploy to.') | ||
| param location string = resourceGroup().location | ||
|
|
||
| @description('Required. The name of the Virtual Network to create.') | ||
| param virtualNetworkName string | ||
|
|
||
| @description('Required. The name of the Managed Identity to create.') | ||
| param managedIdentityName string | ||
|
|
||
| @description('Required. The name of the Deployment Script to create for the SSH Key generation.') | ||
| param sshDeploymentScriptName string | ||
|
|
||
| @description('Required. The name of the SSH Key to create.') | ||
| param sshKeyName string | ||
|
|
||
| resource virtualNetwork 'Microsoft.Network/virtualNetworks@2022-01-01' = { | ||
| name: virtualNetworkName | ||
| location: location | ||
| properties: { | ||
| addressSpace: { | ||
| addressPrefixes: [ | ||
| '10.0.0.0/24' | ||
| ] | ||
| } | ||
| subnets: [ | ||
| { | ||
| name: 'defaultSubnet' | ||
| properties: { | ||
| addressPrefix: '10.0.0.0/24' | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = { | ||
| name: managedIdentityName | ||
| location: location | ||
| } | ||
|
|
||
| resource msiRGContrRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { | ||
| name: guid(resourceGroup().id, 'Contributor', managedIdentity.id) | ||
| scope: resourceGroup() | ||
| properties: { | ||
| principalId: managedIdentity.properties.principalId | ||
| roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c') // Contributor | ||
| principalType: 'ServicePrincipal' | ||
| } | ||
| } | ||
|
|
||
| resource sshDeploymentScript 'Microsoft.Resources/deploymentScripts@2020-10-01' = { | ||
| name: sshDeploymentScriptName | ||
| location: location | ||
| kind: 'AzurePowerShell' | ||
| identity: { | ||
| type: 'UserAssigned' | ||
| userAssignedIdentities: { | ||
| '${managedIdentity.id}': {} | ||
| } | ||
| } | ||
| properties: { | ||
| azPowerShellVersion: '9.0' | ||
| retentionInterval: 'P1D' | ||
| arguments: '-SSHKeyName "${sshKeyName}" -ResourceGroupName "${resourceGroup().name}"' | ||
| scriptContent: loadTextContent('../.scripts/New-SSHKey.ps1') | ||
| } | ||
| dependsOn: [ | ||
| msiRGContrRoleAssignment | ||
| ] | ||
| } | ||
|
|
||
| resource sshKey 'Microsoft.Compute/sshPublicKeys@2022-03-01' = { | ||
| name: sshKeyName | ||
| location: location | ||
| properties: { | ||
| publicKey: sshDeploymentScript.properties.outputs.publicKey | ||
| } | ||
| } | ||
|
|
||
| @description('The resource ID of the created Virtual Network Subnet.') | ||
| output subnetResourceId string = virtualNetwork.properties.subnets[0].id | ||
|
|
||
| @description('The Public Key of the created SSH Key.') | ||
| output SSHKeyPublicKey string = sshKey.properties.publicKey |
86 changes: 86 additions & 0 deletions
86
modules/Microsoft.Compute/virtualMachineScaleSets/.test/linux.min/deploy.test.bicep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| targetScope = 'subscription' | ||
|
|
||
| // ========== // | ||
| // Parameters // | ||
| // ========== // | ||
| @description('Optional. The name of the resource group to deploy for testing purposes.') | ||
| @maxLength(90) | ||
| param resourceGroupName string = 'ms.compute.virtualmachinescalesets-${serviceShort}-rg' | ||
|
|
||
| @description('Optional. The location to deploy resources to.') | ||
| param location 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 = 'cvmsslinmin' | ||
|
|
||
| // =========== // | ||
| // Deployments // | ||
| // =========== // | ||
|
|
||
| // General resources | ||
| // ================= | ||
| resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { | ||
| name: resourceGroupName | ||
| location: location | ||
| } | ||
|
|
||
| module resourceGroupResources 'dependencies.bicep' = { | ||
| scope: resourceGroup | ||
| name: '${uniqueString(deployment().name, location)}-paramNested' | ||
| params: { | ||
| virtualNetworkName: 'dep-<<namePrefix>>-vnet-${serviceShort}' | ||
| managedIdentityName: 'dep-<<namePrefix>>-msi-${serviceShort}' | ||
| sshDeploymentScriptName: 'dep-<<namePrefix>>-ds-${serviceShort}' | ||
| sshKeyName: 'dep-<<namePrefix>>-ssh-${serviceShort}' | ||
| } | ||
| } | ||
|
|
||
| // ============== // | ||
| // Test Execution // | ||
| // ============== // | ||
|
|
||
| module testDeployment '../../deploy.bicep' = { | ||
| scope: resourceGroup | ||
| name: '${uniqueString(deployment().name)}-test-${serviceShort}' | ||
| params: { | ||
| name: '<<namePrefix>>${serviceShort}001' | ||
| adminUsername: 'scaleSetAdmin' | ||
| imageReference: { | ||
| offer: 'UbuntuServer' | ||
| publisher: 'Canonical' | ||
| sku: '18.04-LTS' | ||
| version: 'latest' | ||
| } | ||
| osDisk: { | ||
| createOption: 'fromImage' | ||
| diskSizeGB: '128' | ||
| managedDisk: { | ||
| storageAccountType: 'Premium_LRS' | ||
| } | ||
| } | ||
| osType: 'Linux' | ||
| skuName: 'Standard_B12ms' | ||
| disablePasswordAuthentication: true | ||
| nicConfigurations: [ | ||
| { | ||
| ipConfigurations: [ | ||
| { | ||
| name: 'ipconfig1' | ||
| properties: { | ||
| subnet: { | ||
| id: resourceGroupResources.outputs.subnetResourceId | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| nicSuffix: '-nic01' | ||
| } | ||
| ] | ||
| publicKeys: [ | ||
| { | ||
| keyData: resourceGroupResources.outputs.SSHKeyPublicKey | ||
| path: '/home/scaleSetAdmin/.ssh/authorized_keys' | ||
| } | ||
| ] | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.