Category Archives: Virtualization

Everything related to Virtualization technologies, VMware, HyperV, KVM

Deploy Azure Linux and Windows servers in 10 mins via cli

This is a step by step guide about deploying Linux or Windows servers on Azure via CLI.

Why Cli?

Some people prefer using Linux rather than PowerShell and it seems sometimes easier and faster to learn esp if you’re not GUI type of person.

Installation Options

If you’re working on Windows and would like to use CLI, you’ll have two options to install CLI

Option 1

Run Azure CLI installation directly from your Powershell (PowerShell needs to run from a privileged account)

Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList ‘/I AzureCLI.msi /quiet’

As soon as you run this command, it’ll take about 5 mins or less depending on the connection you have.

clip_image001

Option 2

Download the MSI file directly from MS’s link and install it on your Computer.

https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows?view=azure-cli-latest

Connect to Azure CLI from PowerShell

Run PowerShell or CMD and type the following command to connect

Az Login then hit enter

As soon as you type this, a web page will be launched asking you for your Azure Account credentials so open the session for your Cli window.

The moment you verified your account, PowerShell will list your azure plans that you have / had before.

clip_image002

If you’re going to use Linux (Ubuntu, Debian) flavor then you’d have to following the following instructions

Manual install instructions

If you don’t want to run a script as superuser or the all-in-one script fails, follow these steps to install the Azure CLI.

  1. Get packages needed for the install process:

    bash

    
    
    sudo apt-get update
    sudo apt-get install ca-certificates curl apt-transport-https lsb-release gnupg
  2. Download and install the Microsoft signing key:

    bash

    
    
    curl -sL https://packages.microsoft.com/keys/microsoft.asc |
        gpg --dearmor |
        sudo tee /etc/apt/trusted.gpg.d/microsoft.asc.gpg > /dev/null
  3. Add the Azure CLI software repository:

    bash

    
    
    AZ_REPO=$(lsb_release -cs)
    echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" |
        sudo tee /etc/apt/sources.list.d/azure-cli.list
  4. Update repository information and install the

    azure-cli

    package:

    bash

    
    
    sudo apt-get update
    sudo apt-get install azure-cli

Run the Azure CLI with the

az

command. To sign in, use the az login command.

  1. Run the

    login

    command.

    Azure CLI

    Try It

    
    
    az login

    If the CLI can open your default browser, it will do so and load an Azure sign-in page.

    Otherwise, open a browser page at https://aka.ms/devicelogin and enter the authorization code displayed in your terminal.

  2. Sign in with your account credentials in the browser.

To learn more about different authentication methods, see Sign in with Azure CLI.

Deploying Linux (CentOS):

Creating a Resource Group for Azure Container Instances (ACI)

We will start first by creating a Resource Group for our Machine, calling it a AzureLinuxServersGroup to easily identify that this group contains our Linux Servers

az group create –name AzureLinuxServersGroup –location westeurope

clip_image001[4]

Next we will be creating a container to contain the Linux OS on the resource group which we have just created

First, How we know which Image to use and if that will be proper for our deployment?

To answer that, we will use the following command which will view the available latest edition Linux OS with different flavors.

I would like to use CentOS since its identical to RedHat and used by majority of Enterprises.

To list the Images, Enter the following command

az vm image list –output table

clip_image002[4]

Notice there are many columns, The one which we are going to use in terminal command line is the UrnAlias. It’s important to remember this.

az vm create \

–resource-group AzureLinuxServersGroup \

–name AzureCentOSWP \

–image CentOS \

–admin-username Moh10lyUser \

–generate-ssh-keys

clip_image003

Since we are using Bash, It’s a case sensitive and it complained about user having capital letters. So we’ll go ahead and use small letters

clip_image004

After running the command with small letters, it’s telling us where we can find the keys in order for us to reach and get them to use later to login to this newly created machine.

SSH key files ‘/home/moh10ly/.ssh/id_rsa’ and ‘/home/moh10ly/.ssh/id_rsa.pub’ have been generated under ~/.ssh to allow SSH access to the VM. If using machines without permanent storage, back up your keys to a safe location.

The deployment of the machine takes about 3 mins, and it’ll be created with the default minimum resources. Let’s view

clip_image005

Our machine is ready to be accessed now

clip_image006

In order for you to get the SSH Keys, you’ll have to have a bit of knowledge

I am going to go the location mentioned previously after creating a machine and copy the keys from the bash screen into a file. Save the file and Import it into SSH client which I will be using (Bitvise in my case).

From the bash screen goto cd /

Cd /home/user/.ssh/

Cat id_rsa hit enter and copy the key and save it into notepad.

Cat id_rsa.pub and copy/save into a notepad as the public key.

clip_image007

After loading both keys, I was able to successfully login to the Server

clip_image008

clip_image009

clip_image010

Get a list of Azure VMS

az vm image list

clip_image011

Let’s List and deploy a WordPress on CentOS

To view the list of available CentOS images, we’ll use the following cli command

az vm image list -f CentOS –all

The image needs to be grabbed from dockerhub URL

cognosys:wordpress-with-centos-77-free:wordpress-with-centos-77-free:1.2019.1008

az container create –resource-group mohazbackupgroup –name mohcontainer –os-type Linux –image cognosys:wordpress-with-centos-77-free:wordpress-with-centos-77-free:1.2019.1008 –dns-name-label azmohlinux –ports 22

Create Windows Server core with IIS

az container create –resource-group mohazbackupgroup –name mohcontainer –os-type windows –image mcr.microsoft.com/windoervercore/centos –dns-name-label azmohlinux –ports 22ws/servercore/iis:nanoserver –dns-name-label azmohiis –ports 80

clip_image012

Here we go I got a machine ready (took about 5 mins)

clip_image013

azmohiis.westeurope.azurecontainer.io

To delete the container, you can write the following

az container delete –resource-group mohazbackupgroup –name mohcontainer

clip_image014

clip_image015

Stay tuned for more articles about Azure.

You receive an error 408 when you try to install VMMAgent on HyperV host machine that you would like to add to SCVMM 2012 for management.

You receive an error 408 when you try to install VMMAgent on HyperV host machine that you would like to add to SCVMM for management.

Error (408)

lynchyperv.lab.com has an unsupported version of the Virtual Machine Manager agent installed.

Recommended Action

Uninstall the Virtual Machine Manager agent using Add or Remove Programs on lynchyperv.lab.com, and then try the operation again.

clip_image001

Resolution:

First uninstall any agent on the HyperV host machine.

Then on the SCVMM Server, navigate to the following path

C:\Program Files\Microsoft System Center 2012 R2\Virtual Machine Manager\agents\amd64

clip_image002

Copy the folder 3.2.7895.0 to the Host machine that you want to add it to the VMM server and run to install the agent and try again to add the agent.

As in the below snapshot .. this will work for you

clip_image003
clip_image004

Done

clip_image005

Adding host on VMM causes warning Multipath I/O not enabled for known storage arrays on host x.x.x.x

Installing host agent and configure it on VMM error

When you try to add a new host to the VMM , you get the following warning:

Warning (26179)

Multipath I/O not enabled for known storage arrays on host x.x.x.x

image

Resolution:

In order to resolve this problem, you will have to install two features on the host machine.

To do so, run Windows Powershell as admin

Run the following Cmdlets then

Import-Module ServerManager

Add-WindowsFeature Multipath-IO

image

Once the command is finished it’s recommended to restart the server.

THE APPLICATION ENCOUNTERED AN ERROR WHILE ATTEMPTING TO CHANGE THE STATE OF “VM”

Symptoms: After you finished deploying your Hyper-V server but in this case without the Server connected to the Internet and time is configured properly.

After you have created and configured new VMs and installed them, when you connect your physical Hyper-V host server to the Internet you notice the time changed and your VMs become inaccessible for certificate issue..

here’s the error and how to fix it.

clip_image001[4]

3- EXCHANGE_OI on HASIMI NODE2 –

Action

Media Clipboard View Help

Virtual Machine Connection

The application encountered an error while attempting

to change the state of •g- EXCHANGE 01

•3- EXCHANGE_OI’ could not initialize.

Could not initiallze machine remoting system. Error. •Element not

found.’ (000070490).

not find a usable cetificate. Element not found.’

(0000704″).

•3- EXCHANGE_OI’ could not initialize. (Virtual machine 10

B967FUc-20A2-43BD.83EE.99R321DCD55)

•3- EXCHANGE_OI’ could not initialize machine remoting system. Error:

‘Element not found.'(Ox8D070490). (Virtual machine ID

g967FUc.20A2-43gD.B3EE.g9A2321DCD55)

•3- EXCHANGE_OI’ could not find a usable certificate. Error: ‘Element not

Status: Off

found.’ (oxeoc70490). machine

B967FUc-20A2-a3BD-B3EE-99A2321DCD55)

@ Hide details

Close

Symptoms

If the Hyper-V Host Server doesn’t have internet and you have configured it after creating a VM then the server date will change and the self-signed certificate date will change as it won’t be verified by Hyper V manager and will cause launching the VM to fail to start.

Solution:

Delete old certificate and Create a new Self signed certificate.

To do so open MMC

Navigate to Certificates

clip_image002[4]

In Certificates select Service Account

clip_image003[4]

Choose local computer and click next

clip_image004[4]

Then select the Hyper-V Virtual Machine Management Service account and open

clip_image005[4]

Under the Personal, check the date of the certificate there ..

Delete the certificate

clip_image006[4]

Open Service Console and restart all Hyper-V Services

clip_image007[4]

Once the service is restarted, you’ll see a new certificate that has been automatically created

clip_image008[4]

Now if you try to open the VM console again, it should work.