-
Notifications
You must be signed in to change notification settings - Fork 437
[Modules] Converted Network NetworkWatcher to new dependencies approach #2273
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 17 commits into
main
from
users/alsehr/1791_Network_networkWatcher
Nov 11, 2022
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
deed500
Init
AlexanderSehr 42f3a4b
Update to latest
AlexanderSehr 3a9a013
Added first draft of vm dep
AlexanderSehr 2114f20
Update to latest
AlexanderSehr c3e6eff
Update to latest
AlexanderSehr 37c4b56
Excluded NetworkWatcher from removal
AlexanderSehr b759ca9
Excluded NetworkWatcher from removal
AlexanderSehr e7fd204
Enabled removal in pipelines
AlexanderSehr 03454e1
Adjusted tests & docs
AlexanderSehr c66ac9c
Update to latest
AlexanderSehr 1cbd24e
Added disk removal
AlexanderSehr 43add07
Update to latest
AlexanderSehr f05c219
Added comment
AlexanderSehr 42e58d6
Addressed comments
AlexanderSehr 0401901
Update to latest
AlexanderSehr d6f9b13
Updated names
AlexanderSehr c0f6fd7
Updated names
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
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
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
142 changes: 142 additions & 0 deletions
142
modules/Microsoft.Network/networkWatchers/.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,142 @@ | ||
| @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 first Network Security Group to create.') | ||
| param firstNetworkSecurityGroupName string | ||
|
|
||
| @description('Required. The name of the second Network Security Group to create.') | ||
| param secondNetworkSecurityGroupName string | ||
|
|
||
| @description('Required. The name of the Virtual Machine to create.') | ||
| param virtualMachineName string | ||
|
|
||
| @description('Optional. The password to leverage for the VM login.') | ||
| @secure() | ||
| param password string = newGuid() | ||
|
|
||
| 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 firstNetworkSecurityGroup 'Microsoft.Network/networkSecurityGroups@2022-05-01' = { | ||
| name: firstNetworkSecurityGroupName | ||
| location: location | ||
| } | ||
|
|
||
| resource secondNetworkSecurityGroup 'Microsoft.Network/networkSecurityGroups@2022-05-01' = { | ||
| name: secondNetworkSecurityGroupName | ||
| location: location | ||
| } | ||
|
|
||
| resource networkInterface 'Microsoft.Network/networkInterfaces@2022-05-01' = { | ||
| name: '${virtualMachineName}-nic' | ||
| location: location | ||
| properties: { | ||
| ipConfigurations: [ | ||
| { | ||
| name: 'ipconfig01' | ||
| properties: { | ||
| subnet: { | ||
| id: virtualNetwork.properties.subnets[0].id | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| resource virtualMachine 'Microsoft.Compute/virtualMachines@2022-08-01' = { | ||
| name: virtualMachineName | ||
| location: location | ||
| properties: { | ||
| networkProfile: { | ||
| networkInterfaces: [ | ||
| { | ||
| id: networkInterface.id | ||
| properties: { | ||
| deleteOption: 'Delete' | ||
| primary: true | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| storageProfile: { | ||
| imageReference: { | ||
| offer: 'UbuntuServer' | ||
| publisher: 'Canonical' | ||
| sku: '18.04-LTS' | ||
| version: 'latest' | ||
| } | ||
| osDisk: { | ||
| deleteOption: 'Delete' | ||
| createOption: 'FromImage' | ||
| } | ||
| } | ||
| hardwareProfile: { | ||
| vmSize: 'Standard_B1ms' | ||
| } | ||
| osProfile: { | ||
| adminUsername: '${virtualMachineName}cake' | ||
| adminPassword: password | ||
| computerName: virtualMachineName | ||
| linuxConfiguration: { | ||
| disablePasswordAuthentication: false | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| resource extension 'Microsoft.Compute/virtualMachines/extensions@2021-07-01' = { | ||
| name: 'NetworkWatcherAgent' | ||
| parent: virtualMachine | ||
| location: location | ||
| properties: { | ||
| publisher: 'Microsoft.Azure.NetworkWatcher' | ||
| type: 'NetworkWatcherAgentLinux' | ||
| typeHandlerVersion: '1.4' | ||
| autoUpgradeMinorVersion: true | ||
| enableAutomaticUpgrade: false | ||
| settings: {} | ||
| protectedSettings: {} | ||
| suppressFailures: false | ||
| } | ||
| } | ||
|
|
||
| @description('The principal ID of the created Managed Identity.') | ||
| output managedIdentityPrincipalId string = managedIdentity.properties.principalId | ||
|
|
||
| @description('The resource ID of the created Virtual Machine.') | ||
| output virtualMachineResourceId string = virtualMachine.id | ||
|
|
||
| @description('The resource ID of the first created Network Security Group.') | ||
| output firstNetworkSecurityGroupResourceId string = firstNetworkSecurityGroup.id | ||
|
|
||
| @description('The resource ID of the second created Network Security Group.') | ||
| output secondNetworkSecurityGroupResourceId string = secondNetworkSecurityGroup.id | ||
144 changes: 144 additions & 0 deletions
144
modules/Microsoft.Network/networkWatchers/.test/common/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,144 @@ | ||
| targetScope = 'subscription' | ||
|
|
||
| // ========== // | ||
| // Parameters // | ||
| // ========== // | ||
| @description('Optional. The name of the resource group to deploy for testing purposes.') | ||
| @maxLength(90) | ||
| param resourceGroupName string = 'NetworkWatcherRG' // Note, this is the default NetworkWatcher resource group. Do not change. | ||
|
|
||
| @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 = 'nnwcom' | ||
|
|
||
| // =========== // | ||
| // 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: { | ||
| managedIdentityName: 'dep-<<namePrefix>>-msi-${serviceShort}' | ||
| firstNetworkSecurityGroupName: 'dep-<<namePrefix>>-nsg-1-${serviceShort}' | ||
| secondNetworkSecurityGroupName: 'dep-<<namePrefix>>-nsg-2-${serviceShort}' | ||
| virtualMachineName: 'dep-<<namePrefix>>-vm-${serviceShort}' | ||
| virtualNetworkName: 'dep-<<namePrefix>>-vnet-${serviceShort}' | ||
| location: location | ||
| } | ||
| } | ||
|
|
||
| // Diagnostics | ||
| // =========== | ||
| module diagnosticDependencies '../../../../.shared/dependencyConstructs/diagnostic.dependencies.bicep' = { | ||
| scope: resourceGroup | ||
| name: '${uniqueString(deployment().name, location)}-diagnosticDependencies' | ||
| params: { | ||
| storageAccountName: 'dep<<namePrefix>>diasa${serviceShort}01' | ||
| logAnalyticsWorkspaceName: 'dep-<<namePrefix>>-law-${serviceShort}' | ||
| eventHubNamespaceEventHubName: 'dep-<<namePrefix>>-evh-${serviceShort}' | ||
| eventHubNamespaceName: 'dep-<<namePrefix>>-evhns-${serviceShort}' | ||
| location: location | ||
| } | ||
| } | ||
|
|
||
| // ============== // | ||
| // Test Execution // | ||
| // ============== // | ||
| #disable-next-line no-hardcoded-location // Disabled as the default RG & location are created in always one location, but each test has to deploy into a different one | ||
| var testLocation = 'westeurope' | ||
| module testDeployment '../../deploy.bicep' = { | ||
| scope: resourceGroup | ||
| name: '${uniqueString(deployment().name)}-test-${serviceShort}' | ||
| params: { | ||
| name: 'NetworkWatcher_${testLocation}' | ||
| location: testLocation | ||
| connectionMonitors: [ | ||
| { | ||
| name: '<<namePrefix>>-${serviceShort}-cm-001' | ||
| endpoints: [ | ||
| { | ||
| name: '<<namePrefix>>-subnet-001(${resourceGroup.name})' | ||
| resourceId: resourceGroupResources.outputs.virtualMachineResourceId | ||
| type: 'AzureVM' | ||
| } | ||
| { | ||
| address: 'www.office.com' | ||
| name: 'Office Portal' | ||
| type: 'ExternalAddress' | ||
| } | ||
| ] | ||
| testConfigurations: [ | ||
| { | ||
| httpConfiguration: { | ||
| method: 'Get' | ||
| port: 80 | ||
| preferHTTPS: false | ||
| requestHeaders: [] | ||
| validStatusCodeRanges: [ | ||
| '200' | ||
| ] | ||
| } | ||
| name: 'HTTP Test' | ||
| protocol: 'Http' | ||
| successThreshold: { | ||
| checksFailedPercent: 5 | ||
| roundTripTimeMs: 100 | ||
| } | ||
| testFrequencySec: 30 | ||
| } | ||
| ] | ||
| testGroups: [ | ||
| { | ||
| destinations: [ | ||
| 'Office Portal' | ||
| ] | ||
| disable: false | ||
| name: 'TestHTTPBing' | ||
| sources: [ | ||
| '<<namePrefix>>-subnet-001(${resourceGroup.name})' | ||
| ] | ||
| testConfigurations: [ | ||
| 'HTTP Test' | ||
| ] | ||
| } | ||
| ] | ||
| workspaceResourceId: diagnosticDependencies.outputs.logAnalyticsWorkspaceResourceId | ||
| } | ||
| ] | ||
| flowLogs: [ | ||
| { | ||
| enabled: false | ||
| storageId: diagnosticDependencies.outputs.storageAccountResourceId | ||
| targetResourceId: resourceGroupResources.outputs.firstNetworkSecurityGroupResourceId | ||
| } | ||
| { | ||
| formatVersion: 1 | ||
| name: '<<namePrefix>>-${serviceShort}-fl-001' | ||
| retentionInDays: 8 | ||
| storageId: diagnosticDependencies.outputs.storageAccountResourceId | ||
| targetResourceId: resourceGroupResources.outputs.secondNetworkSecurityGroupResourceId | ||
| trafficAnalyticsInterval: 10 | ||
| workspaceResourceId: diagnosticDependencies.outputs.logAnalyticsWorkspaceResourceId | ||
| } | ||
| ] | ||
| roleAssignments: [ | ||
| { | ||
| roleDefinitionIdOrName: 'Reader' | ||
| principalIds: [ | ||
| resourceGroupResources.outputs.managedIdentityPrincipalId | ||
| ] | ||
| principalType: 'ServicePrincipal' | ||
| } | ||
| ] | ||
| } | ||
| } |
9 changes: 0 additions & 9 deletions
9
modules/Microsoft.Network/networkWatchers/.test/min.parameters.json
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
modules/Microsoft.Network/networkWatchers/.test/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,39 @@ | ||
| targetScope = 'subscription' | ||
|
|
||
| // ========== // | ||
| // Parameters // | ||
| // ========== // | ||
| @description('Optional. The name of the resource group to deploy for testing purposes.') | ||
| @maxLength(90) | ||
| param resourceGroupName string = 'NetworkWatcherRG' // Note, this is the default NetworkWatcher resource group. Do not change. | ||
|
|
||
| @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 = 'nnwmin' | ||
|
|
||
| // =========== // | ||
| // Deployments // | ||
| // =========== // | ||
|
|
||
| // General resources | ||
| // ================= | ||
| resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { | ||
| name: resourceGroupName | ||
| location: location | ||
| } | ||
|
|
||
| // ============== // | ||
| // Test Execution // | ||
| // ============== // | ||
| #disable-next-line no-hardcoded-location // Disabled as the default RG & location are created in always one location, but each test has to deploy into a different one | ||
| var testLocation = 'northeurope' | ||
| module testDeployment '../../deploy.bicep' = { | ||
| scope: resourceGroup | ||
| name: '${uniqueString(deployment().name)}-test-${serviceShort}' | ||
| params: { | ||
| // Note: This value is not required and only set to enable testing | ||
| location: testLocation | ||
AlexanderSehr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
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.