-
Notifications
You must be signed in to change notification settings - Fork 437
[Modules] Refactored Network Application Gateway to new dependency approach #1871
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
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
a2ae459
Started refactoring
AlexanderSehr 95b1cbc
Finished first version
AlexanderSehr 6bacd63
Update to latest
AlexanderSehr a9b9205
Fixed pip deployment
AlexanderSehr 568325a
sync
AlexanderSehr fd3a149
Update to latest
AlexanderSehr 60fbbb5
Update to latest
AlexanderSehr 18b4cbc
Update to latest
AlexanderSehr b7aa360
Updated docs
AlexanderSehr dc2ef2e
Update to latest
AlexanderSehr a1b1968
Updaed script
AlexanderSehr ff67d2e
Updated folder default to common.
AlexanderSehr 323ed0c
Merge branch 'main' into users/alsehr/1791_network_appGw
AlexanderSehr 7135cc4
Update to latest
AlexanderSehr 2ad6e85
Update to latest
AlexanderSehr 374da4a
Update modules/Microsoft.Network/applicationGateways/.test/common/dep…
AlexanderSehr 00b27c7
Merge branch 'main' into users/alsehr/1791_network_appGw
AlexanderSehr d0bff09
Update modules/Microsoft.Network/applicationGateways/.test/common/dep…
AlexanderSehr fb22a97
Update modules/Microsoft.Network/applicationGateways/.test/.scripts/N…
AlexanderSehr ae06a8c
Update modules/Microsoft.Network/applicationGateways/.test/common/dep…
AlexanderSehr 2cb152c
Update to latest
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
40 changes: 40 additions & 0 deletions
40
modules/Microsoft.Network/applicationGateways/.test/.scripts/New-Certificate.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,40 @@ | ||
| param( | ||
| [string] $KeyVaultName, | ||
| [string] $CertName | ||
| ) | ||
|
|
||
| $certificate = Get-AzKeyVaultCertificate -VaultName $KeyVaultName -Name $CertName -ErrorAction 'Stop' | ||
|
|
||
| if (-not $certificate) { | ||
| $policyInputObject = @{ | ||
| SecretContentType = 'application/x-pkcs12' | ||
| SubjectName = 'CN=fabrikam.com' | ||
| IssuerName = 'Self' | ||
| ValidityInMonths = 12 | ||
| ReuseKeyOnRenewal = $true | ||
| } | ||
| $certPolicy = New-AzKeyVaultCertificatePolicy @policyInputObject | ||
|
|
||
| $null = Add-AzKeyVaultCertificate -VaultName $KeyVaultName -Name $CertName -CertificatePolicy $certPolicy | ||
| Write-Verbose ('Initiated creation of certificate [{0}] in key vault [{1}]' -f $CertName, $KeyVaultName) -Verbose | ||
|
|
||
| while (-not (Get-AzKeyVaultCertificateOperation -VaultName $KeyVaultName -Name $CertName).Status -eq 'completed') { | ||
| Write-Verbose 'Waiting 10 seconds for certificate creation' -Verbose | ||
| Start-Sleep 10 | ||
| } | ||
|
|
||
| Write-Verbose 'Certificate created' -Verbose | ||
| } | ||
|
|
||
| $secretId = $certificate.SecretId | ||
| while ([String]::IsNullOrEmpty($secretId)) { | ||
| Write-Verbose 'Waiting 10 seconds until certificate can be fetched' -Verbose | ||
| Start-Sleep 10 | ||
| $certificate = Get-AzKeyVaultCertificate -VaultName $KeyVaultName -Name $CertName -ErrorAction 'Stop' | ||
| $secretId = $certificate.SecretId | ||
| } | ||
|
|
||
| # Write into Deployment Script output stream | ||
| $DeploymentScriptOutputs = @{ | ||
| secretUrl = $secretId | ||
| } | ||
117 changes: 117 additions & 0 deletions
117
modules/Microsoft.Network/applicationGateways/.test/common/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,117 @@ | ||
| @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 Public IP to create.') | ||
| param publicIPName string | ||
|
|
||
| @description('Required. The name of the Managed Identity to create.') | ||
| param managedIdentityName string | ||
|
|
||
| @description('Required. The name of the Key Vault to create.') | ||
| param keyVaultName string | ||
|
|
||
| @description('Required. The name of the Deployment Script to create for the Certificate generation.') | ||
| param certDeploymentScriptName string | ||
|
|
||
| var CertName = 'applicationGatewaySslCertificate' | ||
|
|
||
| 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 publicIP 'Microsoft.Network/publicIPAddresses@2022-01-01' = { | ||
| name: publicIPName | ||
| location: location | ||
| sku: { | ||
| name: 'Standard' | ||
| tier: 'Regional' | ||
| } | ||
| properties: { | ||
| publicIPAllocationMethod: 'Static' | ||
| } | ||
| } | ||
|
|
||
| resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = { | ||
| name: managedIdentityName | ||
| location: location | ||
| } | ||
|
|
||
| resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' = { | ||
| name: keyVaultName | ||
| location: location | ||
| properties: { | ||
| sku: { | ||
| family: 'A' | ||
| name: 'standard' | ||
| } | ||
| tenantId: tenant().tenantId | ||
| enablePurgeProtection: null | ||
| enabledForTemplateDeployment: true | ||
| enabledForDiskEncryption: true | ||
| enabledForDeployment: true | ||
| enableRbacAuthorization: true | ||
| accessPolicies: [] | ||
| } | ||
| } | ||
|
|
||
| resource keyPermissions 'Microsoft.Authorization/roleAssignments@2022-04-01' = { | ||
| name: guid('msi-${managedIdentity.name}-KeyVault-Admin-RoleAssignment') | ||
| scope: keyVault | ||
| properties: { | ||
| principalId: managedIdentity.properties.principalId | ||
| roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '00482a5a-887f-4fb3-b363-3b7fe8e74483') // Key Vault Administrator | ||
| principalType: 'ServicePrincipal' | ||
| } | ||
| } | ||
|
|
||
| resource certDeploymentScript 'Microsoft.Resources/deploymentScripts@2020-10-01' = { | ||
| name: certDeploymentScriptName | ||
| location: location | ||
| kind: 'AzurePowerShell' | ||
| identity: { | ||
| type: 'UserAssigned' | ||
| userAssignedIdentities: { | ||
| '${managedIdentity.id}': {} | ||
| } | ||
| } | ||
| properties: { | ||
| azPowerShellVersion: '8.0' | ||
| retentionInterval: 'P1D' | ||
| arguments: '-KeyVaultName "${keyVault.name}" -CertName "${CertName}"' | ||
| scriptContent: loadTextContent('../.scripts/New-Certificate.ps1') | ||
| } | ||
| } | ||
|
|
||
| @description('The resource ID of the created Virtual Network Subnet.') | ||
| output subnetResourceId string = virtualNetwork.properties.subnets[0].id | ||
|
|
||
| @description('The resource ID of the created Public IP.') | ||
| output publicIPResourceId string = publicIP.id | ||
|
|
||
| @description('The resource ID of the created Managed Identity.') | ||
| output managedIdentityResourceId string = managedIdentity.id | ||
|
|
||
| @description('The URL of the created certificate.') | ||
| output certificateSecretUrl string = certDeploymentScript.properties.outputs.secretUrl | ||
|
|
||
| @description('The principal ID of the created Managed Identity.') | ||
| output managedIdentityPrincipalId string = managedIdentity.properties.principalId |
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.