diff --git a/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/resources/destination.bicep b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/resources/destination.bicep index b43905905..619028be4 100644 --- a/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/resources/destination.bicep +++ b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/resources/destination.bicep @@ -5,17 +5,18 @@ param location string @description('Prefix used in the Naming for multiple Deployments in the same Subscription') param prefix string -@description('Suffix used in the Naming for multiple Deployments in the same Subscription') -param suffix string - @description('Number of the deployment used for multiple Deployments in the same Subscription') param deployment int +@description('User Name for the Tags') +param userName string + + // Resources // https://learn.microsoft.com/en-us/azure/templates/microsoft.network/networksecuritygroups?pivots=deployment-language-bicep @description('Network security group in destination network') resource destinationVnetNsg 'Microsoft.Network/networkSecurityGroups@2022-05-01' = { - name: '${prefix}${deployment}${suffix}-destination-vnet-nsg' + name: '${prefix}${deployment}-${userName}-destination-vnet-nsg' location: location properties: { securityRules: [ @@ -39,7 +40,7 @@ resource destinationVnetNsg 'Microsoft.Network/networkSecurityGroups@2022-05-01' // https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/virtualNetworks?pivots=deployment-language-bicep @description('Virtual network for the destination resources') resource destinationVnet 'Microsoft.Network/virtualNetworks@2022-05-01' = { - name: '${prefix}${deployment}${suffix}-destination-vnet' + name: '${prefix}${deployment}-${userName}-destination-vnet' location: location properties: { addressSpace: { @@ -70,7 +71,7 @@ resource destinationVnet 'Microsoft.Network/virtualNetworks@2022-05-01' = { // https://learn.microsoft.com/en-us/azure/templates/microsoft.network/publicipaddresses?pivots=deployment-language-bicep @description('Destination Bastion Public IP') resource destinationBastionPip 'Microsoft.Network/publicIPAddresses@2022-05-01' = { - name: '${prefix}${deployment}${suffix}-destination-bastion-pip' + name: '${prefix}${deployment}-${userName}-destination-bastion-pip' location: location sku: { name: 'Standard' @@ -83,7 +84,7 @@ resource destinationBastionPip 'Microsoft.Network/publicIPAddresses@2022-05-01' // https://learn.microsoft.com/en-us/azure/templates/microsoft.network/bastionhosts?pivots=deployment-language-bicep @description('Destination Network Bastion to access the destination Servers') resource destinationBastion 'Microsoft.Network/bastionHosts@2022-07-01' = { - name: '${prefix}${deployment}${suffix}-destination-bastion' + name: '${prefix}${deployment}-${userName}-destination-bastion' location: location sku: { name: 'Basic' diff --git a/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/resources/main.bicep b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/resources/main.bicep index 097b0a0f7..44dc5ec42 100644 --- a/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/resources/main.bicep +++ b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/resources/main.bicep @@ -15,9 +15,6 @@ param location string = deployment().location @description('User Name for the Tags') param userName string -@description('Suffix used to make resource names unique') -var suffix = substring(uniqueString(currentUserObjectId), 0, 4) - @description('Tags to identify user resources') var tags = { User: userName @@ -25,7 +22,8 @@ var tags = { @description('Source Resouce Groups.') resource sourceRg 'Microsoft.Resources/resourceGroups@2021-01-01' = [for i in range(0, deploymentCount): { - name: '${prefix}${(i+1)}-${suffix}-source-rg' + //name: '${prefix}${(i+1)}-${suffix}-source-rg' + name: '${prefix}${(i+1)}-${userName}-source-rg' location: location tags: tags }] @@ -38,14 +36,15 @@ module source 'source.bicep' = [for i in range(0, deploymentCount): { location: location currentUserObjectId: currentUserObjectId prefix: prefix - suffix: suffix deployment: (i+1) + userName: userName } }] @description('Destination Resouce Groups.') resource destinationRg 'Microsoft.Resources/resourceGroups@2021-01-01' = [for i in range(0, deploymentCount): { - name: '${prefix}${(i+1)}-${suffix}-destination-rg' + //name: '${prefix}${(i+1)}-${suffix}-destination-rg' + name: '${prefix}${(i+1)}-${userName}-destination-rg' location: location tags: tags }] @@ -57,11 +56,11 @@ module destination 'destination.bicep' = [for i in range(0, deploymentCount): { params: { location: location prefix: prefix - suffix: suffix deployment: (i+1) + userName: userName } }] -output identifier string = suffix +output identifier string = userName diff --git a/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/resources/source.bicep b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/resources/source.bicep index 321fdec41..1b79cd61c 100644 --- a/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/resources/source.bicep +++ b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/resources/source.bicep @@ -10,9 +10,6 @@ param location string @description('Prefix used in the Naming for multiple Deployments in the same Subscription') param prefix string -@description('Suffix used in the Naming for multiple Deployments in the same Subscription') -param suffix string - @description('Number of the deployment used for multiple Deployments in the same Subscription') param deployment int @@ -27,25 +24,29 @@ param guidValue string = newGuid() // Variables @description('Admin user variable') -var adminUsername = '${prefix}${deployment}-microhackadmin' +var adminUsername = '${prefix}${deployment}-${userName}' @description('Admin password variable') var adminPassword = '${toUpper(uniqueString(resourceGroup().id))}-${guidValue}' @description('Create Name for VM1') -var vm1Name = '${prefix}${deployment}${suffix}-fe-1' +var vm1Name = '${prefix}${deployment}-${userName}-fe1' @description('Create Name for VM2') -var vm2Name = '${prefix}${deployment}${suffix}-fe-2' +var vm2Name = '${prefix}${deployment}-${userName}-fe2' @description('Tenant ID used by Keyvault') var tenantId = subscription().tenantId +@description('User Name for the Tags') +param userName string + + // Resources // https://learn.microsoft.com/en-us/azure/templates/microsoft.keyvault/vaults?pivots=deployment-language-bicep @description('Source Keyvault') resource sourceKeyvault 'Microsoft.KeyVault/vaults@2021-11-01-preview' = { - name: substring('${prefix}${deployment}${suffix}-source-kv-${uniqueString(resourceGroup().id)}', 0, 22) + name: substring('${prefix}${deployment}-${userName}-source-kv-${uniqueString(resourceGroup().id)}', 0, 22) location: location properties: { enabledForDeployment: false @@ -93,7 +94,7 @@ resource adminUsernameSecret 'Microsoft.KeyVault/vaults/secrets@2021-11-01-previ // https://learn.microsoft.com/en-us/azure/templates/microsoft.network/networksecuritygroups?pivots=deployment-language-bicep @description('Network security group in source network') resource sourceVnetNsg 'Microsoft.Network/networkSecurityGroups@2022-05-01' = { - name: '${prefix}${deployment}${suffix}-source-vnet-nsg' + name: '${prefix}${deployment}-${userName}-source-vnet-nsg' location: location properties: { securityRules: [ @@ -117,7 +118,7 @@ resource sourceVnetNsg 'Microsoft.Network/networkSecurityGroups@2022-05-01' = { // https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/virtualNetworks?pivots=deployment-language-bicep @description('Virtual network for the source resources') resource sourceVnet 'Microsoft.Network/virtualNetworks@2022-05-01' = { - name: '${prefix}${deployment}${suffix}-source-vnet' + name: '${prefix}${deployment}-${userName}-source-vnet' location: location properties: { addressSpace: { @@ -148,7 +149,7 @@ resource sourceVnet 'Microsoft.Network/virtualNetworks@2022-05-01' = { // https://learn.microsoft.com/en-us/azure/templates/microsoft.network/publicipaddresses?pivots=deployment-language-bicep @description('Source Bastion Public IP') resource sourceBastionPip 'Microsoft.Network/publicIPAddresses@2022-05-01' = { - name: '${prefix}${deployment}${suffix}-source-bastion-pip' + name: '${prefix}${deployment}-${userName}-source-bastion-pip' location: location sku: { name: 'Standard' @@ -161,7 +162,7 @@ resource sourceBastionPip 'Microsoft.Network/publicIPAddresses@2022-05-01' = { // https://learn.microsoft.com/en-us/azure/templates/microsoft.network/bastionhosts?pivots=deployment-language-bicep @description('Source Network Bastion to access the source Servers') resource sourceBastion 'Microsoft.Network/bastionHosts@2022-07-01' = { - name: '${prefix}${deployment}${suffix}-source-bastion' + name: '${prefix}${deployment}-${userName}-source-bastion' location: location sku: { name: 'Basic' @@ -377,7 +378,7 @@ resource vm2Extension 'Microsoft.Compute/virtualMachines/extensions@2022-03-01' // https://learn.microsoft.com/en-us/azure/templates/microsoft.network/loadbalancers?pivots=deployment-language-bicep @description('Loadbalancer for VMs') resource lb 'Microsoft.Network/loadBalancers@2021-08-01' = { - name: '${prefix}${deployment}${suffix}-plb-frontend' + name: '${prefix}${deployment}-${userName}-plb-frontend' location: location sku: { name: 'Standard' @@ -415,10 +416,10 @@ resource lb 'Microsoft.Network/loadBalancers@2021-08-01' = { name: 'myHTTPRule' properties: { frontendIPConfiguration: { - id: resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', '${prefix}${deployment}${suffix}-plb-frontend', 'LoadBalancerFrontEnd') + id: resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', '${prefix}${deployment}-${userName}-plb-frontend', 'LoadBalancerFrontEnd') } backendAddressPool: { - id: resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '${prefix}${deployment}${suffix}-plb-frontend', 'LoadBalancerBackEndPool') + id: resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '${prefix}${deployment}-${userName}-plb-frontend', 'LoadBalancerBackEndPool') } frontendPort: 80 backendPort: 80 @@ -429,7 +430,7 @@ resource lb 'Microsoft.Network/loadBalancers@2021-08-01' = { loadDistribution: 'Default' disableOutboundSnat: true probe: { - id: resourceId('Microsoft.Network/loadBalancers/probes', '${prefix}${deployment}${suffix}-plb-frontend', 'loadBalancerHealthProbe') + id: resourceId('Microsoft.Network/loadBalancers/probes', '${prefix}${deployment}-${userName}-plb-frontend', 'loadBalancerHealthProbe') } } } @@ -454,11 +455,11 @@ resource lb 'Microsoft.Network/loadBalancers@2021-08-01' = { enableTcpReset: false idleTimeoutInMinutes: 15 backendAddressPool: { - id: resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '${prefix}${deployment}${suffix}-plb-frontend', 'LoadBalancerBackEndPoolOutbound') + id: resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '${prefix}${deployment}-${userName}-plb-frontend', 'LoadBalancerBackEndPoolOutbound') } frontendIPConfigurations: [ { - id: resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', '${prefix}${deployment}${suffix}-plb-frontend', 'LoadBalancerFrontEndOutbound') + id: resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', '${prefix}${deployment}-${userName}-plb-frontend', 'LoadBalancerFrontEndOutbound') } ] } @@ -470,7 +471,7 @@ resource lb 'Microsoft.Network/loadBalancers@2021-08-01' = { // https://learn.microsoft.com/en-us/azure/templates/microsoft.network/publicipaddresses?pivots=deployment-language-bicep @description('Load Balancer Public IP') resource lbPublicIPAddress 'Microsoft.Network/publicIPAddresses@2021-08-01' = { - name: '${prefix}${deployment}${suffix}-lbPublicIP' + name: '${prefix}${deployment}-${userName}-lbPublicIP' location: location sku: { name: 'Standard' @@ -484,7 +485,7 @@ resource lbPublicIPAddress 'Microsoft.Network/publicIPAddresses@2021-08-01' = { // https://learn.microsoft.com/en-us/azure/templates/microsoft.network/publicipaddresses?pivots=deployment-language-bicep @description('Load Balancer Outbound Public IP') resource lbPublicIPAddressOutbound 'Microsoft.Network/publicIPAddresses@2021-08-01' = { - name: '${prefix}${deployment}${suffix}-lbPublicIPOutbound' + name: '${prefix}${deployment}-${userName}-lbPublicIPOutbound' location: location sku: { name: 'Standard' diff --git a/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS1-1.png b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS1-1.png new file mode 100644 index 000000000..96ca13a94 Binary files /dev/null and b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS1-1.png differ diff --git a/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS1.png b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS1.png new file mode 100644 index 000000000..d7f918db4 Binary files /dev/null and b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS1.png differ diff --git a/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS2.png b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS2.png new file mode 100644 index 000000000..0a77e0c55 Binary files /dev/null and b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS2.png differ diff --git a/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS3.png b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS3.png new file mode 100644 index 000000000..013296050 Binary files /dev/null and b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS3.png differ diff --git a/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS4.png b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS4.png new file mode 100644 index 000000000..0703d402a Binary files /dev/null and b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS4.png differ diff --git a/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS5.png b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS5.png new file mode 100644 index 000000000..226fb790b Binary files /dev/null and b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS5.png differ diff --git a/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS6.png b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS6.png new file mode 100644 index 000000000..5d34997f9 Binary files /dev/null and b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS6.png differ diff --git a/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS7.png b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS7.png new file mode 100644 index 000000000..74152dc8d Binary files /dev/null and b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/img/CS7.png differ diff --git a/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/solution.md b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/solution.md index 8ec1aaf37..d800de402 100644 --- a/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/solution.md +++ b/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/walkthrough/challenge-1/solution.md @@ -10,14 +10,41 @@ Duration: 30 minutes ### **Task 1: Deploy the Landing Zone for the Micro Hack** -- Install the [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) on your local PC. You can also use Azure Cloud Shell. -- Open a PowerShell (Windows) or Bash (Linux and macOS) terminal window -- Execute `az login` and sign in with your Azure AD account -- Execute `az deployment sub create --name "$(az ad signed-in-user show --query displayName -o tsv)-$(az ad signed-in-user show --query id -o tsv)" --location germanywestcentral --template-file ./main.bicep --parameters currentUserObjectId=$(az ad signed-in-user show --query id -o tsv) --parameters userName="$(az ad signed-in-user show --query displayName -o tsv)"` -- Wait for the deployment to finish +- Open the [Azure Portal](https://portal.azure.com) and login using a user account with at least Contributor permissions on a Azure Subscription. Start the Azure Cloud Shell from the Menu bar on the top. + +![image](./img/CS1.png) + +> [!NOTE] +> You can also use your local PC but make sure to install [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli). + +- If this is the first time that Cloud Shell is beeing started, create the required Storage Account by selecting *Bash* and clicking on *Create storage* and wait until the Storage Accounts has been created. + +![image](./img/CS1-1.png) + +![image](./img/CS2.png) + +- Make sure to select *Bash*. + +![image](./img/CS3.png) + +- Clone the MicroHack Github repository using the `git clone https://github.com/microsoft/MicroHack.git` command. + +![image](./img/CS4.png) + +- Change into to Migrate & Modernize Microhack directory of the cloned repository using the `cd MicroHack/03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization/resources` command. + +![image](./img/CS5.png) + +- Execute `az deployment sub create --name "$(az ad signed-in-user show --query displayName -o tsv)-$(uuidgen)" --location germanywestcentral --template-file ./main.bicep --parameters currentUserObjectId=$(az ad signed-in-user show --query id -o tsv) --parameters userName="$(az ad signed-in-user show --query displayName -o tsv)"` + +![image](./img/CS6.png) + +- Wait for the deployment to finish. You can view the deployment from the Azure portal by selecting the Azure Subscription and click on *Deployments* from the navigation pane on the left. + +![image](./img/CS7.png) > [!NOTE] -> Please note that the deployment may take up to 10 minutes +> Please note that the deployment may take up to 10 minutes. ### **Task 2: Verify the deployed resources** The bicep deployment should have created the following resources