NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

$rgName = "opswagposh"
$location = "eastus"

New-AzureRmResourceGroup -Name $rgName -Location $location

$vnetName = "$($rgName)-vnet"
$publicIPName = "$($rgName)-ip"
$gwName = "$($rgName)-gw"

# Create backend subnet
$backendSubnetConfig = New-AzureRmVirtualNetworkSubnetConfig `
-Name myBackendSubnet `
-AddressPrefix 10.0.1.0/24
# Create gateway subnet
$agSubnetConfig = New-AzureRmVirtualNetworkSubnetConfig `
-Name myAGSubnet `
-AddressPrefix 10.0.2.0/24
# Create the virtual network
New-AzureRmVirtualNetwork `
-ResourceGroupName $rgName `
-Location $location `
-Name $vnetName `
-AddressPrefix 10.0.0.0/16 `
-Subnet $backendSubnetConfig, $agSubnetConfig

# Provision a public IP address
$charSet = "abcdefghijklmnopqrstuvwxyz0123456789".ToCharArray()
$uniqueString = ""
for ($x = 0; $x -lt 5; $x++) {
$uniqueString += $charSet | Get-Random
}

New-AzureRmPublicIpAddress `
-ResourceGroupName $rgName `
-Location $location `
-Name $publicIPName `
-AllocationMethod Dynamic `
-DomainNameLabel "$($rgName)$($uniqueString)"

$vnet = Get-AzureRmVirtualNetwork -ResourceGroupName $rgName -Name $vnetName

$secpasswd = ConvertTo-SecureString 'demo@pass123' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ("demouser", $secpasswd)

for ($i=1; $i -le 2; $i++)
{
Write-Verbose -Message "Creating VM $i of 2" -Verbose
$nic = New-AzureRmNetworkInterface `
-Name myNic$i `
-ResourceGroupName $rgName `
-Location $location `
-SubnetId $vnet.Subnets[1].Id
$vm = New-AzureRmVMConfig `
-VMName myVM$i `
-VMSize Standard_B2ms
$vm = Set-AzureRmVMOperatingSystem `
-VM $vm `
-Windows `
-ComputerName myVM$i `
-Credential $cred
$vm = Set-AzureRmVMSourceImage `
-VM $vm `
-PublisherName MicrosoftWindowsServer `
-Offer WindowsServer `
-Skus 2016-Datacenter `
-Version latest
$vm = Add-AzureRmVMNetworkInterface `
-VM $vm `
-Id $nic.Id
$vm = Set-AzureRmVMBootDiagnostics `
-VM $vm `
-Disable

New-AzureRmVM -ResourceGroupName $rgName -Location $location -VM $vm

$publicSettings = @{ "fileUris" = (,"https://raw.githubusercontent.com/Azure/azure-docs-powershell-samples/master/application-gateway/iis/appgatewayurl.ps1");"commandToExecute" = "powershell -ExecutionPolicy Unrestricted -File appgatewayurl.ps1" }

Write-Verbose -Message "Provisioning Custom Script Extension on VM $i of 2" -Verbose
Set-AzureRmVMExtension `
-ResourceGroupName $rgName `
-ExtensionName IIS `
-VMName myVM$i `
-Publisher Microsoft.Compute `
-ExtensionType CustomScriptExtension `
-TypeHandlerVersion 1.4 `
-Settings $publicSettings `
-Location $location
}

# Create IP configs and frontend port
Write-Verbose -Message "Creating IP configurations and frontend ports" -Verbose
$vnet = Get-AzureRmVirtualNetwork -ResourceGroupName $rgName -Name $vnetName
$pip = Get-AzureRmPublicIPAddress -ResourceGroupName $rgName -Name $publicIPName
$subnet=$vnet.Subnets[0]
$gipconfig = New-AzureRmApplicationGatewayIPConfiguration `
-Name myAGIPConfig `
-Subnet $subnet
$fipconfig = New-AzureRmApplicationGatewayFrontendIPConfig `
-Name myAGFrontendIPConfig `
-PublicIPAddress $pip
$frontendport = New-AzureRmApplicationGatewayFrontendPort `
-Name myFrontendPort `
-Port 80

# Create the backend pool
Write-Verbose -Message "Creating backend pool" -Verbose
$address1 = Get-AzureRmNetworkInterface -ResourceGroupName $rgName -Name myNic1
$address2 = Get-AzureRmNetworkInterface -ResourceGroupName $rgName -Name myNic2
$backendPool = New-AzureRmApplicationGatewayBackendAddressPool `
-Name myAGBackendPool `
-BackendIPAddresses $address1.ipconfigurations[0].privateipaddress, $address2.ipconfigurations[0].privateipaddress
$poolSettings = New-AzureRmApplicationGatewayBackendHttpSettings `
-Name myPoolSettings `
-Port 80 `
-Protocol Http `
-CookieBasedAffinity Enabled `
-RequestTimeout 120


# Create the listener and rule
Write-Verbose -Message "Creating default listener and rule" -Verbose
$defaultlistener = New-AzureRmApplicationGatewayHttpListener `
-Name myAGListener `
-Protocol Http `
-FrontendIPConfiguration $fipconfig `
-FrontendPort $frontendport
$frontendRule = New-AzureRmApplicationGatewayRequestRoutingRule `
-Name rule1 `
-RuleType Basic `
-HttpListener $defaultlistener `
-BackendAddressPool $backendPool `
-BackendHttpSettings $poolSettings

# Create the gateway
Write-Verbose -Message "Creating the gateway" -Verbose
$sku = New-AzureRmApplicationGatewaySku `
-Name Standard_Medium `
-Tier Standard `
-Capacity 2
New-AzureRmApplicationGateway `
-Name $gwName `
-ResourceGroupName $rgName `
-Location $location `
-BackendAddressPools $backendPool `
-BackendHttpSettingsCollection $poolSettings `
-FrontendIpConfigurations $fipconfig `
-GatewayIpConfigurations $gipconfig `
-FrontendPorts $frontendport `
-HttpListeners $defaultlistener `
-RequestRoutingRules $frontendRule `
-Sku $sku


# Get the gateway IP
$ip = Get-AzureRmPublicIPAddress -ResourceGroupName $rgName -Name $publicIPName

Write-Verbose -Message "IP Address of Gateway: $($ip.IpAddress)" -Verbose
Write-Verbose -Message "Host name of Gateway: $($ip.DnsSettings.Fqdn)" -Verbose
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.