Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -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: {
Expand Down Expand Up @@ -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'
Expand All @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ 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
}

@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
}]
Expand All @@ -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
}]
Expand All @@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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: [
Expand All @@ -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: {
Expand Down Expand Up @@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand All @@ -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')
}
}
}
Expand All @@ -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')
}
]
}
Expand All @@ -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'
Expand All @@ -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'
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down