You are browsing the archive for Azure PowerShell.

Azure PowerShell: Your Azure credentials have not been set up or have expired (classic – ASM)

8:56 am in ASM, Azure, Azure PowerShell, PowerShell by Wim Matthyssen

Last week, after a long time I was cleaning up an Azure ASM environment with Azure PowerShell for a customer when I stumbled upon the following error:

“Your Azure credentials have not been set up or have expired, please run Add-AzureAccount to set up your Azure credentials.”

clip_image002

After checking the account settings, everything seemed valid. So probably for some reason, some old settings were cached causing the problem.

clip_image004

Solution:

After trying and testing out some cmdlets, the following finally solved the issue:

clip_image005

When you have run the above cmdlet, try to run the Add-AzureAccount cmdlet and afterwards any other cmdlet to see if this also solves the issue for you.

clip_image007

Hope this helps you when you are facing the same issue.

Wim Matthyssen (@wmatthyssen)

Azure IaaS: Deploying B-series VMs

10:18 am in ARM, Azure, Azure PowerShell, B-Series VMs, IaaS, PowerShell, Public Cloud by Wim Matthyssen

Last week Microsoft introduced the B-Series VM size in preview. These B-Series VMs can run workloads that burst in their performance, but do not need continuous full performance of the CPU. Servers that would be eligible for this new “burstable” VM size are servers with small databases, webservers, development servers, quality assurance (QA) and test servers. But also servers with other workloads that do not utilize the full located vCPUs are grate candidates to benefit and lower costs by using a B-Series VM.

clip_image002

Herby a list of the 6 B-Series VM sizes, which are currently available in Preview in the following Azure Regions (Europe-West, US-West 2, US-East, Asia Pacific-Southeast):

Instance Size vCPU vMemory: GiB Tempory Storage / Local SSD: GiB Max data disks Max NICs Credits banked / hour Max Banked Credits
Standard_B1s 1 1 2 2 2 6 144
Standard_B2s 2 4 8 4 3 24 576
Standard_B1ms 1 2 4 2 2 12 288
Standard_B2ms 2 8 16 4 3 36 864
Standard_B4ms 4 16 32 8 4 54 1296
Standard_B8ms 8 32 64 16 4 81 1944

You can also read more about this new VM size here and find all pricing info

Now I am going to show you how you can deploy a new B-Series VM trough Azure PowerShell.

First, you need to request quota to be able to deploy this B-Series VMs. To do so you should logon to the Azure portal and go to Help + support. To request an increase or to be able to deploy B-Series VMs, select New support request.

clip_image004

You need to create a Quota support case for Cores. So, on the NEW SUPPORT REQUEST page, select Issue type as “Quota” and Quota type as “Cores”. Also, select the Subscription and the correct Support plan. Click Next.

clip_image006

Select Severity “C – Minimal Impact”, Deployment model “Resource Manager” and the correct Location, which in my case is West Europe. Select as SKU Families that requires an increase “BS Series” and set the NEW LIMIT higher than before, for example 15 instead of 10. Click Next.

clip_image008

In the Contact Information blade, select your Preferred contact method, provide a Response time, select your preferred Language and fill in the Contact Information. Click Create to create the new support ticket.

clip_image010

clip_image012

In my case I received an email after the quota was been approved, which normally does not take that much time. So from here we can go further with the deployment.

clip_image014

If you open Azure PowerShell, and run following commands, you can now built a new B-Series VM. You can copy the commands or save them to as a PowerShell script (.ps1). Do not forget to adjust all variables were needed.

clip_image016

clip_image018

Hope this helps you getting started with this new B-Series VMs.

Wim Matthyssen (@wmatthyssen)

Azure Backup: Create a Recovery Services vault with Azure PowerShell

9:46 am in Azure, Azure Backup, Azure PowerShell, PowerShell, Public Cloud, Recovery Services vault by Wim Matthyssen

A Recovery Services vault is an online storage entity used to backup workloads to the Azure cloud. You can use it to hold backup data for various Azure services such as IaaS VMs (Linux or Windows) and Azure SQL databases, but it can also be used by System Center Data Protection Manager (SCDPM) or Azure Backup Server (MABS v1 and MABS v2) to enable cloud backups.

clip_image002[5]

These days it is quite easy to create or manage a Recovery Services vault through the Azure portal, but it is even faster when you make use of a scripting language like Azure PowerShell to automate the setup. Therefore, below you can find the PowerShell script I mostly use to do all the work for me. You can just copy and paste or you can download the complete script (.ps1) from the Microsoft TechNet gallery.

To use the script, first adjust all variables to your use. Afterwards login into an Azure PowerShell window as an administrator and when asked login with the credentials for your Azure Subscription.

The script will first create a Resource Group and then the Recovery Services vault in your Azure Subscription. At the end, it will also set the storage redundancy for the newly created vault. Keep in mind that you can only use Locally Redundant Storage (LRS) or Geo Redundant Storage (GRS).

clip_image004[6]

clip_image006[6]

clip_image008[5]

Useful Azure PowerShell cmdlets for Azure Backup

List all available Azure Backup PowerShell cmdlets

clip_image010[7]

List all available Recovery Services vaults in your subscription

clip_image012[4]

Hope this post helps you when you start using Azure Backup.

Wim Matthyssen (@wmatthyssen)

Azure PowerShell: Migrate an Azure ASM Virtual IP address (VIP) to an ARM Public IP address (PIP)

12:13 pm in ARM, ASM, Azure, Azure PowerShell, Cloud, PIP, Public Cloud, Public IP address, VIP, Virtual IP address by Wim Matthyssen

The last weeks, I am assisting some customers with the migration of their existing Azure Service Manager (ASM) VMs to the Azure Resource Manager (ARM) portal. Most of those workloads are migrated with the use of Azure Site Recovery (ASR). The only thing ASR cannot handle for the moment is the migration of the Cloud Services Virtual IP Address (VIP). This public IP address can for example used by an IIS website running on a specific IaaS virtual machine (VM) which is part of that Cloud Service. You can work around this problem, as in many of these cases, by using Azure PowerShell. Below I will wake you through this process with an example.

Overview used Azure VMs:

clip_image002
1) First, we need to login and prepare the ARM environment. To do so run following PowerShell commands (change variables as needed):

clip_image004

clip_image006

2) Next we need to login to the ASM environment

clip_image008

3) As the next step we need to reserve the public IP Address

clip_image010

4) Next we need to de-associate the Reserverd IP address from the Cloud Service. Press Yes when asked

clip_image012

clip_image014

5) When you now check the list of reserved IP addresses, it will show the reserved IP address 40.68.191.13 as unassigned. The attribute InUse is set to False and the ServiceName and DeploymentName attributes are empty

clip_image016

6) Also check if the Reserved IP address is valid for migration

clip_image018

7) Next we need to prepare the Reserved IP address for migration

clip_image020

8) Now run the following PowerShell command to finalize the migration of the Reserved IP address

clip_image022

9) You can verify the availability of the migrated Public IP address by login in to the Azure portal. Under Public IP address, you should see the resource with the correct IP address

clip_image024

clip_image026

10) Now, you can move this resource to the correct resource group. When you do so, and your asked to Confirm the move, click Yes

clip_image028

clip_image030

clip_image032

11) Afterwards you can assign the public IP address to whichever resource you would like

clip_image034

clip_image036

That concludes this blog post. Hope it comes to your use.

Wim Matthyssen (@wmatthyssen)

Azure IaaS: VM status Running (Installing Extensions)

6:13 am in ASM, Azure, Azure PowerShell, Cloud, IaaS, Installing Extension, Microsoft, Public Cloud by Wim Matthyssen

Last week while migrating Azure IaaS VMs from ASM to ARM, I noticed that one VM was showing the status “Running (Installing Extension)” in the Azure Classic portal. When I tried to connect to that specific VM with RDP no connection could be made. This status also prevented me from doing some automation activities, the VM however still responded to a ping.

clip_image002

When I opened the DASHBOARD page of the VM and looked at the extensions, I saw that the Microsoft.Compute.VMAccessAgent showed following error:

clip_image003

The simplest way I found to resolve this error was to delete the extension, and add it back. To do so login to the Azure portal with your Azure account. Go to Virtual Machines and click on the specific VM. On the opened blade select Extensions, right click the VMAccessAgent and click Delete. When asked to delete the extension select Yes

clip_image005

clip_image006

clip_image007

clip_image008

To reinstall the VMAccess extension open PowerShell ISE, connect to your Azure subscription with your Azure account and run the following command (replace cloud service name and VM name by your own)

clip_image010

To check the current status of the extension, run following command (replace cloud service name and VM name by your own):

clip_image012

Or you can also check trough both Azure portals

clip_image014

clip_image016

After the reinstallation of the VMAccessAgent, it ran with STATUS Success and I was able to reconnect to the VM with RDP. This concludes this blog post, hope it helps whenever you have this issue.

Wim Matthyssen (@wmatthyssen)

An RDP connection to the Azure RemoteApp custom VM fails with the following error: “No Remote Desktop License Servers available”

3:35 pm in Azure, Azure PowerShell, Azure RemoteApp, RDP, W2K12R2 by Wim Matthyssen

A while ago I was setting up Azure RemoteApp at a client. After creating the custom image, I was unable to connect to the newly created Azure IaaS virtual machine (VM) with RDP. The below Remote Desktop Connection error popped up:

clip_image001

The error is caused because the 120-day licensing grace period for the Remote Desktop Server role has expired and you need to install licenses. Which in my opinion is really strange because it’s a new VM created from the Windows Server RDSHwO365P image available at the Azure Marketplace. This being said below you can found out how I finally was able to connect to the VM with RDP.

1) First of all, save a local copy of the RDP file from the Azure portal. I saved it under the C:\Temp folder on my laptop

clip_image003

clip_image005

clip_image007

2) Open Windows PowerShell ISE as an Administrator and run the following PowerShell command prompt to connect. This command will disable licensing for just that connection (change AZUTST by your own RDP file name):

clip_image009

Be aware that only 2 connections are possible at the same time when using /admin.

3) Like you can see below, by using /admin I was able to connect to the VM

clip_image011

clip_image012

clip_image013

clip_image015

This concludes this blog post, hope it helps!

Wim Matthyssen (@wmatthyssen)

Clean up Azure PowerShell when using different Azure subscriptions

12:34 pm in Azure, Azure PowerShell, Azure subscription, Cloud, PowerShell by Wim Matthyssen

Hi all,

These days I’m working on several Azure projects for different clients. As a result, my default subscription data file which is used by Azure PowerShell is completely filled up with settings from those different subscriptions. Frequently, I notice that Azure PowerShell mixes up all this information and does not perform as expected. I strongly assume this is caused by the cached credentials and other elements. In order to fix this, I regulary clean up my Azure PowerShell to have a better overview and to accomplish a better working scripting environment. Below you can find the Azure PowerShell cmdlets to clear a specific customer’s Azure subscription from Azure PowerShell. I will also show you how you can clear your complete Azure profile.

Delete a specific Azure subscription from PowerShell

1) Open up PowerShell ISE as an Administrator and run the following PowerShell cmdlets to list all Azure subscriptions available in the default subscription data file on the computer in use, which can be found under the following location C:\Users\%username%\AppData\Roaming\Windows Azure PowerShell and is named AzureProfile.json

clip_image002

2) To delete a specific subscription from the date file run the below cmdlet (adjust for your own purpose). You may be sure that this cmdlet will not delete the subscription from Azure in any way. You can use this cmdlet with the -Force parameter to suppress the confirmation prompt

clip_image004

3) If the above cmdlet ran without any errors the specific subscription will not be shown anymore when you’re re run the Get-AzureSubscription cmdlet and it should also be cleared from the subscription data file

Clear your complete Azure Profile

1) Open up PowerShell ISE as an Administrator and run the following PowerShell cmdlets to completely clear your Azure Profile on the computer in use

clip_image006

2) If the cmdlet ran without any errors your Azure Profile should be cleared.

This ends this short blog post, hope it helps and till next time!

Wim Matthyssen (@wmatthyssen)