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:

Login-AzureRmAccount
select-azurermsubscription -SubscriptionName “My Subscription”

$rgName=”Resourcegroupname”
$locName=”EastUS”
$vnetName=”vnet_name”

# to check subnet index use:   Get-AzureRmVirtualNetwork -Name msps –ResourceGroupName $rgName | Select Subnets
$subnetIndex=1
$name=”yourvmname”

$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: https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-ps-create-preconfigure-windows-resource-manager-vms/

if you have a lot of numbered disks: http://sc.scomurr.com/arm-recreating-vm-off-existing-vhds/

Microsoft doc: https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-create-windows-powershell-resource-manager/

Advertisements

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

account.windowsazure.com

logon as the subscription owner

open the subscription and go to Edit Subscription Details

SNAGHTML5ba51bf

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

SNAGHTML5bbf349

 

After that the subscription should be visible under portal.azure.com 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!

 

https://azure.microsoft.com/en-us/documentation/articles/active-directory-aadconnect-version-history/#1091310%20

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!

iOS

Microsoft Word: https://itunes.apple.com/us/app/microsoft-word/id586447913?mt=8

Microsoft Excel: https://itunes.apple.com/us/app/microsoft-excel/id586683407?mt=8

Microsoft PowerPoint: https://itunes.apple.com/us/app/microsoft-powerpoint/id586449534?mt=8

Microsoft OneDrive: https://itunes.apple.com/us/app/onedrive-cloud-storage-for/id477537958?mt=8

Microsoft OneNote for iPhone: https://itunes.apple.com/us/app/microsoft-onenote-for-iphone/id410395246?mt=8

Microsoft OneNote for iPad: https://itunes.apple.com/nl/app/microsoft-onenote-voor-ipad/id478105721?mt=8

Microsoft Intune Managed Browser: https://itunes.apple.com/us/app/microsoft-intune-managed-browser/id943264951?mt=8

Work Folders: https://itunes.apple.com/us/app/work-folders/id950878067?mt=8

OWA for iPhone: https://itunes.apple.com/us/app/owa-for-iphone/id659503543?mt=8

Lync: https://itunes.apple.com/us/app/lync-2013-for-iphone/id605841731?mt=8

RD Client: https://itunes.apple.com/us/app/microsoft-remote-desktop/id714464092?mt=8

Sunrise Calendar: https://itunes.apple.com/us/app/sunrise-calendar-outlook-app/id599114150?mt=8

Office Lens: https://itunes.apple.com/us/app/office-lens/id975925059?mt=8

OneDrive for Business: https://itunes.apple.com/us/app/onedrive-for-business-replaced/id655772279?mt=8

Office 365 Admin: https://itunes.apple.com/us/app/office-365-admin/id761397963?mt=8

Office 365 Message Encryption Viewer: https://itunes.apple.com/us/app/office-365-message-encryption/id942328937?mt=8

SharePoint Newsfeed: https://itunes.apple.com/us/app/sharepoint-newsfeed/id595847617?mt=8

Office Sway: https://itunes.apple.com/us/app/office-sway/id929856545?mt=8

Dynamics CRM: https://itunes.apple.com/us/app/dynamics-crm-for-phones-express/id723891307?mt=8

Azure Authenticator: https://itunes.apple.com/us/app/azure-authenticator/id983156458?mt=8

MyApps: https://itunes.apple.com/us/app/my-apps-azure-active-directory/id824048653?mt=8

PowerBI: https://itunes.apple.com/us/app/microsoft-power-bi/id929738808?mt=8

Office Delve: https://itunes.apple.com/us/app/office-delve-for-office-365/id969258781?mt=8

RMS Sharing: https://itunes.apple.com/us/app/rms-sharing/id689516635?mt=8

Office 365 Video: https://itunes.apple.com/us/app/office-365-video-for-iphone/id953685679?mt=8

Outlook: https://itunes.apple.com/us/app/microsoft-outlook/id951937596?mt=8

Android

Microsoft Word: https://play.google.com/store/apps/details?id=com.microsoft.office.word

Microsoft Excel: https://play.google.com/store/apps/details?id=com.microsoft.office.excel

Microsoft PowerPoint: https://play.google.com/store/apps/details?id=com.microsoft.office.powerpoint

Microsoft OneDrive: https://play.google.com/store/apps/details?id=com.microsoft.skydrive

Microsoft Intune Managed Browser: https://play.google.com/store/apps/details?id=com.microsoft.intune.mam.managedbrowser&hl=en

Microsoft Intune PDF Viewer: https://play.google.com/store/apps/details?id=com.microsoft.intune.mam.pdfviewer&hl=en

Microsoft Intune Image Viewer: https://play.google.com/store/apps/details?id=com.microsoft.intune.mam.imageviewer&hl=en

Microsoft Intune AV Player: https://play.google.com/store/apps/details?id=com.microsoft.intune.mam.avplayer&hl=en

Microsoft Office Hub: https://play.google.com/store/apps/details?id=com.microsoft.office.officehub

Office Lens: https://play.google.com/store/apps/details?id=com.microsoft.office.officelens

Microsoft Account: https://play.google.com/store/apps/details?id=com.microsoft.msa.authenticator

Sunrise Calendar: https://play.google.com/store/apps/details?id=am.sunrise.android.calendar

Outlook: https://play.google.com/store/apps/details?id=com.microsoft.office.outlook

OneNote: https://play.google.com/store/apps/details?id=com.microsoft.office.onenote

Remote Desktop Client: https://play.google.com/store/apps/details?id=com.microsoft.rdc.android

Lync 2013: https://play.google.com/store/apps/details?id=com.microsoft.office.lync15

Office Remote: https://play.google.com/store/apps/details?id=com.microsoft.office.officeremote

Keyboard for Excel: https://play.google.com/store/apps/details?id=com.microsoft.keyboardforexcel

OWA for Android: https://play.google.com/store/apps/details?id=com.microsoft.exchange.mowa

Office 365 Admin: https://play.google.com/store/apps/details?id=com.ms.office365admin

MyApps: https://play.google.com/store/apps/details?id=com.microsoft.myapps

OneNote: https://play.google.com/store/apps/details?id=com.microsoft.office.onenote.wear

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.

SNAGHTML10c9266f

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 Outlook.com (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 Gmail.com. 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

SNAGHTML9554a11d 

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: azure.automation.service@gmail.com 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
   $ss=””
   ForEach ($vm in $vms ) {
      if ($vm.Status -ne “StoppedDeallocated”) {$ss=$ss+$vm.name+” – “+$vm.Status + “`r`n”}
   }
   if ($ss -ne “”) {
      $mail_body= ‘Attention! One or more VMs are in a state other than “Stopped (Deallocated)”‘ `
      +”`r`n”+$ss
      Send-MailMessage -SmtpServer smtp.gmail.com -Port 587 -Credential $Gmailcreds `
         -UseSsl -From ‘azure.automation.service@gmail.com’ -To ‘alex.ignatenko@onx.com’ `
         -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

SNAGHTML8b4564ad

 

The information was found in Sandrino’s blog here: http://fabriccontroller.net/blog/posts/migrating-your-windows-server-2003-workloads-to-microsoft-azure/

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.