Followers

Thursday, 7 December 2023

6.Implement a SQL Server Database on an Azure VM

 Implement a SQL Server Database on an Azure VM

  1. Once logged into the Azure portal, click Create resources.

    Type sql server 2019 on Windows Server 2019 and select this resource.

    For Select a plan choose Free SQL Server License SQL 2019 Developer... and click Create.

  2. On the Create a virtual machine page:

    • Resource Group: Click the dropdown to select existing resource group

      Virtual machine name: SQL-ACWEB-7777

      Size: Select See all sizes and B2s, click Select

      Username: delmar

      Password and Confirm password: Insert your password.

  3. Click Review & create and select Create.

    Note: This will take some time to provision. Time to make some tea!

  4. Select Go to resource and copy the Public IP address.

  5. Select Connect and click Download RDP File.

    If you have a Windows laptop, this should already have a pre-installed RDP client.

    1. Open the RDP file using your native RDP client.

    2. When prompted, use the credentials located in our hands-on lab, and click Continue on the pop-up window. Next, you'll be using RDP to log into the VM.

    If you have a Mac laptop, follow these steps to RDP into the Windows VM:

    1. To connect to a Windows VM from a Mac, you will need to install an RDP client such as Microsoft Remote Desktop.

    2. Once downloaded open the application.

    3. In the Mircosoft Remote Desktop, click on the gear and choose the Import from RDP file and select the RDP file that was downloaded earlier.

      When prompted, use the credentials located in our hands-on lab, and click Continue on the pop-up window.

Restore a SQL Server Database from a Prior Backup

  1. Once you are in the VM, close out the Server Manager.

  2. Open Internet Explorer, click through the many prompts choosing the defaults, and paste in the following link:

    https://github.com/linuxacademy/content-azure-database-administrator-associate/blob/master/Hands-on%20Labs/Implement%20an%20SQL%20Server%20database%20on%20an%20Azure%20VM/acweb.bak

  3. On the Internet Explorer pop-up, select Add throughout each prompt, and finally press close.

  4. In GitHub on the content-azure-database-administrator-associate page, click download.

    Once again, on the Internet Explore pop-up, select Add throughout each prompt, and finally press close.

    Again, click download in GitHub, and click Save, and Open folder.

    In the File Explorer, right-click the acweb.bak file and select Copy.

    Click on This PC and navigate Windows (C:).

    Click thru: Program Files >> Microsoft SQL Server >> MSSQL15MSSQLSERVER >> MSSQL >> Backup and right-click to paste the acweb.bak in this path.

  5. Go to the Windows start icon (bottom-left), and choose Microsoft SQL Server Tools 18 >> Microsoft SQL Server Management.

    Note: This will take some time to open. Don't forget to water any plants you have!

  6. Click Connect.

  7. Right-click on Databases >> Restore Database. On the Restore Database page:

    • Select Device as the source.

      Choose the three-dot menu in the Device field.

      Select Add and the acweb.bak file, click OK.

      On Select backup devices and click OK.

      On the Restore Database page, click OK.

  8. Once restored, select OK.

  9. In the Microsoft SQL Server Management Studio page, expand Databases >> acweb >> Tables.

  10. In this tables view, you'll see these restored tables as sales.xxx. Right-click and choose Select Top 1000 Rows to see the contents of the table.

5.Creating Azure Standard Load Balancers with PowerShell

 Creating Azure Standard Load Balancers with PowerShell

  • Creating variables to store key parameters.

  • Identifying the proper cmdlets to create a frontend IP configuration, backend address pool, health probe, Load Balancer rule configuration, and NAT rules.

  • Creating the Azure Standard Load Balancer using the correct parameters.

    Create the Variables

    1. Click the Cloud Shell icon (>_) at the top of the page.

    2. Click PowerShell.

    3. Click Show advanced settings.

    4. Use the combo box under Cloud Shell region to select West US.

    5. Under Storage account, click the radio button for Use existing.

    6. In the box under File share, enter "shell".

    7. Click Create storage.

    8. Identify the current resource group.

      get-azresourcegroup

    9. Select the ResourceGroupName value and copy it to the clipboard.

    10. Create a variable and set it to the value copied in the previous step.

      $resource='RESOURCE_GROUP_NAME'

    11. Set the location variable.

      $location='westus'

    12. Create the public IP address.

      $publicIP = New-AzPublicIpAddress ` -ResourceGroupName $resource ` -Name 'myPublicIp' ` -Location $location ` -AllocationMethod static ` -Sku Standard

    13. Create the frontend IP configuration.

      $feip = New-AzLoadBalancerFrontendIpConfig -Name 'MyFrontEndPool' -PublicIPAddress $publicIP

    14. Create the backend address pool.

      $bepool = New-AzLoadBalancerBackEndAddressPoolConfig -Name 'myBackEndPool'

    15. Create the health probe.

      $probe = New-AzLoadBalancerProbeConfig ` -Name 'myHealthProbe' ` -Protocol Http ` -Port 80 ` -RequestPath / ` -IntervalInSeconds 360 ` -ProbeCount 5

    16. Create the Load Balancer rule.

      $rule = New-AzLoadBalancerRuleConfig ` -Name 'myLoadBalancerRuleWeb' ` -Protocol Tcp ` -Probe $probe ` -FrontendPort 80 ` -BackendPort 80 ` -FrontendIpConfiguration $feip ` -BackendAddressPool $bepool

    17. Create the necessary NAT rules.

      $natrule1 = New-AzLoadBalancerInboundNatRuleConfig ` -Name 'myLoadBalancerRDP1' ` -FrontendIpConfiguration $feip ` -Protocol tcp ` -FrontendPort 4221 ` -BackendPort 3389 $natrule2 = New-AzLoadBalancerInboundNatRuleConfig ` -Name 'myLoadBalancerRDP2' ` -FrontendIpConfiguration $feip ` -Protocol tcp ` -FrontendPort 4222 ` -BackendPort 3389 $natrule3 = New-AzLoadBalancerInboundNatRuleConfig ` -Name 'myLoadBalancerRDP3' ` -FrontendIpConfiguration $feip ` -Protocol tcp ` -FrontendPort 4223 ` -BackendPort 3389

    Create the Azure Standard Load Balancer

    1. Create the Load Balancer.

      New-AzLoadBalancer ` -ResourceGroupName $resource ` -Name 'myLoaBalancer' ` -Sku Standard ` -Location $location ` -FrontendIpConfiguration $feip ` -BackendAddressPool $bepool ` -Probe $probe ` -LoadBalancingRule $rule ` -InboundNatRule $natrule1,$natrule2,$natrule3

4.Create VM using powershell AzureRM

 

Create variables to store the location and resource group names.

$location= "local"
$ResourceGroupName = "myResourceGroup"

New-AzureRmResourceGroup -Name $ResourceGroupName
-Location $location

Create variables to store the storage account name and the storage account SKU information

$StorageAccountName = "mystorageaccount"
$SkuName = "Standard_LRS"

Create a new storage account

$StorageAccount = New-AzureRMStorageAccount -Location $location
-ResourceGroupName $ResourceGroupName
-Type $SkuName
-Name $StorageAccountName

Set-AzureRmCurrentStorageAccount -StorageAccountName $storageAccountName
-ResourceGroupName $resourceGroupName

Create a subnet configuration

$subnetConfig = New-AzureRmVirtualNetworkSubnetConfig -Name mySubnet
-AddressPrefix 192.168.1.0/24

Create a virtual network

$vnet = New-AzureRmVirtualNetwork -ResourceGroupName $ResourceGroupName
-Location $location
-Name MyVnet
-AddressPrefix 192.168.0.0/16 `
-Subnet $subnetConfig

Create a public IP address and specify a DNS name

$pip = New-AzureRmPublicIpAddress -ResourceGroupName $ResourceGroupName
-Location $location
-AllocationMethod Static
-IdleTimeoutInMinutes 4 `
-Name "mypublicdns$(Get-Random)"

Create an inbound network security group rule for port 3389

$nsgRuleRDP = New-AzureRmNetworkSecurityRuleConfig -Name myNetworkSecurityGroupRuleRDP
-Protocol Tcp
-Direction Inbound
-Priority 1000
-SourceAddressPrefix *
-SourcePortRange *
-DestinationAddressPrefix *
-DestinationPortRange 3389 `
-Access Allow

Create an inbound network security group rule for port 80

$nsgRuleWeb = New-AzureRmNetworkSecurityRuleConfig -Name myNetworkSecurityGroupRuleWWW
-Protocol Tcp
-Direction Inbound
-Priority 1001
-SourceAddressPrefix *
-SourcePortRange *
-DestinationAddressPrefix *
-DestinationPortRange 80 `
-Access Allow

Create a network security group

$nsg = New-AzureRmNetworkSecurityGroup -ResourceGroupName $ResourceGroupName
-Location $location
-Name myNetworkSecurityGroup
-SecurityRules $nsgRuleRDP,$nsgRuleWeb

Create a virtual network card and associate it with public IP address and NSG

$nic = New-AzureRmNetworkInterface -Name myNic
-ResourceGroupName $ResourceGroupName
-Location $location
-SubnetId $vnet.Subnets[0].Id
-PublicIpAddressId $pip.Id
-NetworkSecurityGroupId $nsg.Id

Define a credential object to store the username and password for the VM

$UserName='demouser'
$Password='Password@123'| ConvertTo-SecureString -Force -AsPlainText
$Credential=New-Object PSCredential($UserName,$Password)

Create the VM configuration object

$VmName = "VirtualMachinelatest"
$VmSize = "Standard_A1"
$VirtualMachine = New-AzureRmVMConfig
-VMName $VmName
-VMSize $VmSize

$VirtualMachine = Set-AzureRmVMOperatingSystem -VM $VirtualMachine
-Windows
-ComputerName "MainComputer"
-Credential $Credential -ProvisionVMAgent

$VirtualMachine = Set-AzureRmVMSourceImage -VM $VirtualMachine
-PublisherName "MicrosoftWindowsServer"
-Offer "WindowsServer"
-Skus "2016-Datacenter" `
-Version "latest"

Sets the operating system disk properties on a VM.

$VirtualMachine = Set-AzureRmVMOSDisk -VM $VirtualMachine
-CreateOption FromImage |
Set-AzureRmVMBootDiagnostics -ResourceGroupName $ResourceGroupName
-StorageAccountName $StorageAccountName -Enable |`
Add-AzureRmVMNetworkInterface -Id $nic.Id

Create the VM.

New-AzureRmVM -ResourceGroupName $ResourceGroupName
-Location $location `
-VM $VirtualMachine

Connect to the VM

Get-AzureRmPublicIpAddress `
-ResourceGroupName $ResourceGroupName | Select IpAddress

RDP to VM

mstsc /v <publicIpAddress>

#Install IIS via PowerShell

Install-WindowsFeature -name Web-Server -IncludeManagementTools

Delete the VM

Remove-AzureRmResourceGroup `
-Name $ResourceGroupName

 

12. Creating a Hub and Spoke Network with a DMZ and Allowing Access to Azure Arc and Other Microsoft URLs from the Azure Portal

12. Creating a Hub and Spoke Network with a DMZ and Allowing Access to Azure Arc and Other Microsoft URLs from the Azure Portal. 1. Create a...