Monday, January 23, 2017

How to install PowerShell ARM

In your Azure portal, you will create Storage account, VMs, Search Services, Web apps, Virtual Network and DNS, Database servers, Third-party applications. If you want to manage and deploy them as a group, then ARM is the key point.

By using an ARM you can create, update, delete all the resource group in a single operation.

Here I have listed down the main terms that ARM used. (Copy-paste from MSTF Docs.)

  • Resource - A manageable item that is available through Azure. Some common resources are a virtual machine, storage account, web app, database, and virtual network, but there are many more.
  • Resource group - A container that holds related resources for an Azure solution. The resource group can include all the resources for the solution, or only those resources that you want to manage as a group. You decide how you want to allocate resources to resource groups based on what makes the most sense for your organization. See Resource groups.
  • Resource provider - A service that supplies the resources you can deploy and manage through Resource Manager. Each resource provider offers operations for working with the resources that are deployed. Some common resource providers are Microsoft.Compute, which supplies the virtual machine resource, Microsoft.Storage, which supplies the storage account resource, and Microsoft.Web, which supplies resources related to web apps. See Resource providers.
  • Resource Manager template - A JavaScript Object Notation (JSON) file that defines one or more resources to deploy to a resource group. It also defines the dependencies between the deployed resources. The template can be used to deploy the resources consistently and repeatedly. See Template deployment.
  • declarative syntax - Syntax that lets you state "Here is what I intend to create" without having to write the sequence of programming commands to create it. The Resource Manager template is an example of declarative syntax. In the file, you define the properties for the infrastructure to deploy to Azure.

If you are using an ARM , there are some benefits. specially you can save your time on doing same thing again and again in Azure portal,

I'll now show the steps that we need to follow to install ARM in your PowerShell. 

To use the cmdlets, you need to install and configure Azure PowerShell to connect it to your account.

Step 1: Install

Following are the two methods by which you can install Azure PowerShell. You can install it either from the PowerShell Gallery or from  the WebPI.

  • Installing Azure PowerShell from the PowerShell Gallery

To use PowerShell Gallery. You need the PowerShellGet module to use the PowerShell Gallery. This is available here: PowerShellGallery.com

Install the latest Azure PowerShell from the PowerShell Gallery using an elevated Windows PowerShell or PowerShell Integrated Scripting Environment (ISE) prompt using the following commands:

+ Install the Azure Resource Manager modules from the PowerShell Gallery


  Install-Module AzureRM

+ Install the Azure Service Management module from the PowerShell Gallery


  Install-Module Azure

PS C Install —Module AzureRM

More about these commands

  • Install-Module AzureRM installs a rollup module for the Azure Resource Manager cmdlets. The AzureRM module depends on a particular version range for each Azure Resource Manager module. The included version range assures that no breaking module changes can be included when installing AzureRM modules with the same major version. When you install the AzureRM module, any Azure Resource Manager module that has not previously been installed will be downloaded and installed from the PowerShell Gallery.

  • Install-Module Azure installs the Azure module. This module is the Service Management module from Azure PowerShell 0.9.x. This should have no major changes and be interchangeable for the previous version of the Azure module.

Then you can test the Azure connectivity  by typing below command, 

PS C:\Windows\system32> Login-AzureRmAccount

PS Logi n—AzureRmAccount

If you can get the below mentioned windows means, You are good to go with it.

Sign in to your account 
Microsoft Azure 
Work or school, or personal Microsoft account 
hemale@yahoo.com 
Password 
Sign in 
Can't access your account? 
x

PS Logi n—AzureRmAccount 
Environment 
Accou nt 
Tenantld 
Subscr i pt i onld 
Subscr i pt i onName 
CurrentStor ageAccount 
PS 
: Azur«loud 
. Visual Studio Enterprise

[Solved] The requested session access is denied

 

This is a known error message for IT Administrators. But I'll highlight the options that are available to mitigate this issue.

You will face this issue when you try to connect into, 

Azure virtual Server 

Windows 2012 Server 

Windows 2008/20008 R2 Server 

The requested session access is denied. 
OK

First, you need to check whether your enter you Admin credentials on the same RDP window is working. This would be working.

Then run the MTSC without Admin (mstsc /admin) and give your user credentials.

If that is an Azure VPC, without clicking the Connect tab on the VM control page, you can copy the Virtual machine IP address or the FQDN and use the normal RDP connection to connect.

In Azure, you can find the VPC details under Essentials tab.

Essentials 
Resource group (cunge) 
Running 
Location 
West Europe 
Subscription name (change) 
Microsoft Azure Enterprise 
Subscription ID 
Computer name 
Operating system 
Windows 
Standard DS13 (8 cores, 56 GB memory) 
NS name label 
westeurope.cloudap... 
Virtual network/subnet

Hope this will help.

Wednesday, January 4, 2017

How to Resize/Expand Windows Azure VM OS Disk

 

Here I'm going to show the steps that you can follow to expand your Azure VM Operating system Disk.  
There are a couple of ways to do this and here I'm using the PowerShell to do the work .    
 
First, you can try to run the below command on your PowerShell and check whether you can connect to your Microsoft Azure account in resource management (ARM) mode. 
 
PS C:\Windows\system32> Login-AzureRmAccount
 
If this doesn't give an Azure portal sign-in window, then first you have to install the ARM or the latest version of the 
Azure powershell from the   Gallery using an elevated Windows PowerShell. (ARM installation steps will post in the next post)   
 
Then you can test the Azure connectivity  by typing below command, 
 
PS C:\Windows\system32> Login-AzureRmAccount

PS Logi n—AzureRmAccount

If you can get the below mentioned windows means, you can go into the next step.

Sign in to your account 
Microsoft Azure 
Work or school, or personal Microsoft account 
hemale@yahoo.com 
Password 
Sign in 
Can't access your account? 
x

PS Logi n—AzureRmAccount 
Environment 
Accou nt 
Tenantld 
Subscr i pt i onld 
Subscr i pt i onName 
CurrentStor ageAccount 
PS 
: Azur«loud 
. Visual Studio Enterprise

If you are using PowershellISE then this will be easy for you to run the below script. Copy and paste the below script and  Copy and paste the correct values for

Name_of_the_Azure_subscription, Name_of_the_Resource_Group, Name_of_the_Server and give the correct capacity for the OS Disk.

Login-AzureRmAccount
Select-AzureRmSubscription -SubscriptionName 'Name_of_the_Azure_subscription'
$rgName = 'Name_of_the_Resource_Group'
$vmName = 'Name_of_the_Server'
$vm = Get-AzureRmVM -ResourceGroupName $rgName -Name $vmName
Stop-AzureRmVM -ResourceGroupName $rgName -Name $vmName
$vm.StorageProfile.OSDisk.DiskSizeGB = 1023
Update-AzureRmVM -ResourceGroupName $rgName -VM $vm
Start-AzureRmVM -ResourceGroupName $rgName -Name $vmName

Untitledl.psl* X 
4 
Log i n —Azur eRmAccount 
Sel ect—AzureRmSubscription —Subscripti onName 'Visual Studio Enterprise' 
SrgName 
Server ' 
SvmName 
'WIn2016DC' 
Svm 
SrgName -Name 
SvmName 
Get-AzureRmVN -ResourceGr oupName 
Stop-AzureRmVM —ResourceGroupName SrgName -Name 
SvmName 
Svm Storageprofile. OSDiskL DiskSizeG8 = 1023 
Update—AzureRmW -ResourceGroupName 
Sr g Name —VY Svm 
SrgName -Name 
SvmNamel 
Start—AzureRmVM -ResourceGroupName

You can download this from here.

Once you run the Script, It will ask for the credentials. Give that and hit Sign in.

Sign in to your account 
Microsoft Azure 
Work or school, or personal Microsoft account 
hemale@yahoo.com 
Password 
Sign in 
Can't access your account? 
x

This information window will pop up and you can hit yes.

Virtual machine stopping operation 
This cmdlet will stop the specified virtual machine. Do you want to continue?

PS Logi n—AzureRmAccount 
Select—AzureRmSubscription -SubscriptionName 'Visual Studio Enterprise' 
Sr gName 
Server ' 
SvmName 
• Win 2016DC 
Svm = Get-AzureRmW —ResourceGroupName SrgName SvmName 
Stop-AzureRmW —ResourceGroupName SrgName —Name SvmName 
Svm. StorageProfi le. OSDisk.DiskSizeG8 = 1023 
Update—AzureRmW -ResourceGroupName -W' Svm 
Start—AzureRmW SrgName —Name SvmName 
Environment 
Accou nt 
Tenantld 
Subscr i pt i onld 
Subscr i pt i onName 
CurrentStor ageAccount 
: Azur«loud 
. Visual Studio Enterprise 
Account 
Environment 
Subs cri pt ion 
Tenant 
: Azur«loud 
WARNING: Breaking change notice: In 
n Storageprofile and Networkprofile, 
upcoming releaese, 
respectively. 
top level properties, 
DataDiskNames and NetworkInterfaceIDs , 
will 
be renoved from VY object because they are also i

Once the task completed, you will get the below "Succeeded" alert with the Start, Stop time.

Operati onld : 
. Succeeded 
Status 
Start Ti me 
: 03/01/2017 14:57:58 
EndTime 
: 03/01/2017 14:58:00 
Er ror

Connect into your VM and go into "Disk Management". You will see the Unallocated space. From there you will be able to extend the OS Disk.

Computer Management 
File Action View Help 
Computer Management (Local 
System Tools 
Task Scheduler 
Event Viewer 
Shared Folders 
Local Users and Groups 
Performance 
Device Manager 
Storage 
Windows Server 
Disk Management 
Services and Applications 
Volume 
Temporary Storage (D:) 
out 
Simple 
Simple 
Basic 
Basic 
File 
NTFS 
NTFS 
em 
Status 
Healthy (System, Boot, Active, Crash Dump, Primary 
Healthy (Page File, Primary Partition) 
Basic 
102300 
Online 
Basic 
700 
Online 
12700 G8 NTFS 
Healt (System, Boot, Active, Crash D 
Temporary Storage (D:) 
700 NTFS 
Healthy (Page File, Primary Partition) 
8-9600 
Unallocated 
Unallocated Primary partition

Hope this helps you to expand  your Azure VM OS Disk.