IT Consultant Everyday Notes

Just some problems/solutions storage

Category Archives: Azure

Azure: Migrate an Azure VM v2 (ARM-based) between two storage accounts

One of my Customers asked me to move some VMs from expensive Premium storage account to a cheaper Standard tier.

The infrastructure was built using Resource Mode and luckily we do not need to convert VHDs to OS disks (as it is required for Classic VMs).

1. I shutdown/deprovision VM (you do not need to delete it)

2. Copy VHD OS disk and data disk to the new storage account

3. Recreate VM at the new place using the following script:

select-azurermsubscription -SubscriptionName “My Subscription”


# to check subnet index use:   Get-AzureRmVirtualNetwork -Name msps –ResourceGroupName $rgName | Select Subnets

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

$vm=New-AzureRmVMConfig -VMName $name -VMSize Standard_D4
$vm | Set-AzureRmVMOSDisk -VhdUri https://*******.vhd –Name $name -CreateOption attach -Windows -Caching ReadWrite

$vm | Add-AzureRMVMDataDisk -Name “XXXX-data” -VhdUri https://*****-data01.vhd -LUN 0 -Caching ReadWrite -CreateOption Attach -DiskSizeinGB 1023

$nicName= $name + “_nic”
$pipName= $name + “_pip”
$domName= $name
$pip=New-AzureRmPublicIpAddress -Name $pipName –ResourceGroupName $rgName-DomainNameLabel $domName -Location $locName -AllocationMethod Dynamic
$nic=New-AzureRmNetworkInterface -Name $nicName –ResourceGroupName $rgName-Location $locName -SubnetId $vnet.Subnets[$subnetIndex].Id -PublicIpAddressId $pip.Id -PrivateIpAddress $privIP
$vm=Add-AzureRmVMNetworkInterface -VM $vm  -Id $nic.Id

New-AzureRMVM -ResourceGroupName Sharepoint -Location “East US” -VM $vm –Verbose

The machine is recreated and started

here are some useful links I used:

if you have a lot of numbered disks:

Microsoft doc:


Azure: Subscription is not visible in Azure Portal after move between accounts in EA Portal



I moved a subscription from one account in my Enterprise Agreement Portal to another. After that subscription disappeared form Azure portal of the admin of the first account and never appeared in the portal of the admin of the second account.

MS case was escalated to Microsoft Engineering team, but resolution was actually pretty easy: It looks like subscription administrator gets corrupted during transfer. TO fix it go to

logon as the subscription owner

open the subscription and go to Edit Subscription Details


remove garbage under Service Administrator and put the proper Administrator Live ID there:



After that the subscription should be visible under for that Admin.

Azure: Azure AD Connect version history

Azure team keeps updating Azure AD Connect tool much more often than I thought Smile

New features/fixes every month!

Azure: StoreSimple videos

Intune: Microsoft Application links for IOS and Android

Joe Kuster compiled a list of links we can use with Intune to populate Corp Portal with MS apps. Thank you Joe!


Microsoft Word:

Microsoft Excel:

Microsoft PowerPoint:

Microsoft OneDrive:

Microsoft OneNote for iPhone:

Microsoft OneNote for iPad:

Microsoft Intune Managed Browser:

Work Folders:

OWA for iPhone:


RD Client:

Sunrise Calendar:

Office Lens:

OneDrive for Business:

Office 365 Admin:

Office 365 Message Encryption Viewer:

SharePoint Newsfeed:

Office Sway:

Dynamics CRM:

Azure Authenticator:



Office Delve:

RMS Sharing:

Office 365 Video:



Microsoft Word:

Microsoft Excel:

Microsoft PowerPoint:

Microsoft OneDrive:

Microsoft Intune Managed Browser:

Microsoft Intune PDF Viewer:

Microsoft Intune Image Viewer:

Microsoft Intune AV Player:

Microsoft Office Hub:

Office Lens:

Microsoft Account:

Sunrise Calendar:



Remote Desktop Client:

Lync 2013:

Office Remote:

Keyboard for Excel:

OWA for Android:

Office 365 Admin:



Azure: How to add W10 VM


Our company has MPN subscription to Azure. For some reasons Microsoft decided not to add Windows 10 template to Gallery and I needed to do it manually.

Josh Heffner has a nice description of the process.

I created a 10GB OS disk. It is quicker to download, but VM disk need to be expanded. I used the following procedure to resize the VM OS disk;

NOTE: I am using version 0.9.7 of Powershell Azure Module. Earlier versions may not support the disk resize.

Assuming Azure PS model is already installed.

1. I sign-in with my Microsoft account using Add-AzureAccount

2. Checked my Subscriptions using Get-AzureSubscription

3. Select subscription using Slelect-AzureSubscription “Microsoft Partner Network”

4. Check available disks using Get-AzureDisk | ft Label, AttachedTo, DiskName –AutoSize

5. Extend OS disk of my windows 10 VM using Update-AzureDisk –DiskName <DISKNAME> –ResizedSizeInGB 120 –label TinyVMOS

Note. The VNM must be in “StopppedDeallocated” state. You can Shutdown VM from Azure Console or from Powershell. Shutdown from OS itself is not enough.

Note 2: It tool 10 min between shutdown and the moment powershell command recognized that and proceeded resizing.


Azure Automation: Send Email from Azure Automation Script via GMAIL

I am working with Azure Automation scripts. One of them stops all my Lab VMs after working hours to save some money. Script is based on one from Automation Gallery, but I wanted to add a notification feature.

There are several posts about using O365 for this, but I do not think it is a good idea since 0365 is not free.

I tried (AKA Hotmail) first, trying to stick with Microsoft platform, but did not get any success (authentication kept failed for me). So, the second choice was From some posts I understood Azure does not have root certificates from GMAIL CA and SSL connection does not work. To workaround the issue I downloaded Google root certificate and created a Certificate Asset in Automation console


Interesting enough I do not need to use it in my script apparently simply existence of it is enough….

Here is the script to check if all machines are in stop(Deallocated) state and send email otherwise. The script uses a PS Credential Asset: ‘Azure Credentials’ and my MSDN Platform subscription.

I created a test account at Gmail: and add an Automation Asset (PS Credentials) including Gmail user name and password – “Gmailcreds” that allows do not put user name/password in the script.

workflow test-mail
   $Cred = Get-AutomationPSCredential -Name ‘Azure Credentials’
   $Gmailcreds = Get-AutomationPSCredential -Name ‘Gmailcerds’
   Add-AzureAccount -Credential $Cred
   Select-AzureSubscription -SubscriptionName “MSDN Platforms”   
   $vms = Get-AzureVM
   ForEach ($vm in $vms ) {
      if ($vm.Status -ne “StoppedDeallocated”) {$ss=$ss+$” – “+$vm.Status + “`r`n”}
   if ($ss -ne “”) {
      $mail_body= ‘Attention! One or more VMs are in a state other than “Stopped (Deallocated)”‘ `
      Send-MailMessage -SmtpServer -Port 587 -Credential $Gmailcreds `
         -UseSsl -From ‘’ -To ‘’ `
         -Subject ‘Alarm: Azure Automation – Running VM!’ -body $mail_body

This script can be added to schedule to run every night.

Server 2003: Migration to Azure

In my test Lab I migrated Server 2003 VM to the Cloud. The matter in fact it is not enough just copy VHD to Azure using

Add-AzureVhd [-Destination] <Uri> [-LocalFilePath] <FileInfo> [[-NumberOfUploaderThreads] <Int32> ] [[-BaseImageUriToPatch] <Uri> ] [[-OverWrite]] [ <CommonParameters>]

command in Azure PowerShell

It as also necessary to add the copied disk to inventory using:

Add-AzureDisk [-DiskName] <String> [-MediaLocation] <String> [-Label <String> ] [-OS <String> ] [ <CommonParameters>]

In my case the script looks like



The information was found in Sandrino’s blog here:

SCCM 2012: Azure-based cloud Distribution Point

SCCM 2012 SP1 introduces a new feature – cloud-based Distribution Point (DP). The DP must be based in Microsoft Azure.

Peter blogged here step-by-step for the DP creation.