Category: Microsoft

Filter for Azure VMs and Azure Arc Machines

Inventory for Azure Arc enabled Servers

Azure Arc for Servers allows you to manage servers running in your on-premises location, at the edge, or in a multi-cloud environment directly from the Azure portal. There are many features available to manage these hybrid Azure Arc enabled servers, like Log Analytics or Azure Arc Machine extensions. However, one of the basic features of Azure Arc enabled Servers, is that you can now get an inventory and overview of all your servers. This allows you to see and manage your Azure Arc enabled servers next to your Azure resources.

Inventory for Azure Arc enabled Servers and Azure VMs

Inventory for Azure Arc enabled Servers and Azure VMs.

You can see that your Azure Arc enabled servers show up as Azure resources. You can use the filter to limit the view to only Azure virtual machines (VMs), and Azure Arc enabled servers.



Hyper-V VM Stop-VM failed to change state

Force Hyper-V Virtual Machine VM to turn off

In this blog post, we are going to have a look at how you can force a Hyper-V virtual machine (VM) to turn off using the HCSDiag tool. A couple of days ago I had an issue where I wasn’t able to shut down and turn off a Hyper-V virtual machine (VM). After I tried to shut down the Hyper-V VM using the Hyper-V Manager the VM was in a locked state and I couldn’t really do anything with it. Of course the first thing I tried using the PowerShell Stop-VM cmdlet with the force parameter to turn off the virtual machine.

Hyper-V VM Stop-VM failed to change state

Hyper-V VM Stop-VM failed to change state

But as you can see I had no success. Luckily I remembered a tool called the Hyper-V Host Compute Service Diagnostics Tool (HCSDiag.exe), which provides me with a couple of advanced options when it comes to Hyper-V virtual machine, container, and Windows Sandbox management.

The Hyper-V Host Compute Service Diagnostics Tool (HCSDiag.exe) is available in Windows 10 and Windows Server 2019 if you have the Hyper-V roles or virtualization features enabled, and can be helpful to troubleshoot Hyper-V containers, virtual machines (VMs), Windows Sandbox, Windows Defender Application Guard, Windows Subsystem for Linux 2 and more.

Hyper-V Get-VM list VMiD

Hyper-V Get-VM list VM ID

HCSDiag allows me to list all the running Hyper-V containers, including virtual machines. With the HCSDiag kill command, I can then force the Hyper-V VM to turn off.

Force Turn Off of Hyper-V virtual machine VM

Force Turn Off of Hyper-V virtual machine VM

I hope this post was helpful if you have a Hyper-V VM which you can’t turn off. If you have any questions, feel free to leave a comment. You can find more information about the HCSDiag tool, how it works with containers and other tools here on my blog.



Eject ISO from Hyper-V VM using PowerShell

Eject ISO from Hyper-V VM using PowerShell

This is one of these quick and dirty blog posts mostly as a note for myself. Hyper-V offers the capability to add an ISO image to a virtual CD/DVD drive and you can use Hyper-V Manager to do that, or you can also use PowerShell. Here is how you can eject or remove an ISO from a Hyper-V virtual machine (VM) using PowerShell.

This works with Hyper-V on Windows Server and on Windows 10.

Remove or eject ISO from Hyper-V VM using PowerShell

To remove or eject the ISO file from a Hyper-V VM virtual DVD drive, you can use the following PowerShell command:

Find the right DVD drive

Get-VMDvdDrive -VMName "Windows10"

Eject the ISO file from the Hyper-V VM

Get-VMDvdDrive -VMName "Windows10" | Set-VMDvdDrive -Path $null

You can also pipe these commands

Get-VM -VMName "Windows10" | Get-VMDvdDrive | Set-VMDvdDrive -Path $null

If you have multiple DVD drives and controllers on VM, you can also use the following command to be more specific on which ISO to eject.

Set-VMDvdDrive -VMName Windows10 -ControllerNumber 0 -ControllerLocation 1 -Path $null

You can also simply add an ISO to the Hyper-V virtual DVD drive:

Get-VMDvdDrive -VMName "Windows10" | Set-VMDvdDrive -Path "C:\ISO\myisofile.iso"

Be aware that it takes a moment until the ISO file is removed from the virtual DVD drive. You can find more information on the Set-VMDvdDrive cmdlet on Microsoft Docs.

Conclusion

If you want to build some automation around Hyper-V on Windows 10 or on Windows Server, PowerShell is the way to go. If you have any questions feel free to leave a comment.



Connect Azure Cloud Shell to virtual network vNet

Connect Azure Cloud Shell to Virtual Network vNet

As you know, Azure Cloud Shell is a great management tool to manage your Azure resources. Azure Cloud Shell is an interactive, authenticated, browser-accessible shell for managing Azure resources. It provides the flexibility of choosing the shell experience that best suits the way you work, either Bash or PowerShell. You can learn more about Azure Cloud Shell here. If you wanted to manage Azure resources such as Azure virtual machines (VMs), you needed to connect to a public IP address of a virtual machine, which really didn’t work in all scenarios. With the latest update, you can now connect Azure Cloud Shell to an Azure virtual network (vNet). With the new method, you can now deploy the Azure Cloud Shell container within your virtual network (vNet), which now allows you to use PowerShell remoting, SSH, or other command-line tools such as kubctl using private IP addresses.

Requirements

Before you can use Cloud Shell in your own Azure Virtual Network, you will need to create some resources to support this functionality. 

  • Virtual Network – The virtual network in which the resources are located you want to manage or the network that peers with a virtual network where your Azure resources are.
  • Subnet – In that virtual network you will need a dedicated subnet to host Cloud Shell containers.
  • Network profile
  • Azure Relay – An Azure Relay allows two endpoints that are not directly reachable to communicate.
  • Storage Account – The storage account needs to be accessible from the virtual network that is used by Cloud Shell.

There are also some considerations you need to be aware of, such as currently supported Azure regions during the preview, Azure Relay adds additional cost and slower startup speed of Cloud Shell containers. You can learn more about the requirements here.

Connect Azure Cloud Shell to a virtual network

To make the deployment easy, there are Azure Resource Manager templates available to deploy the necessary network and storage resources. In my step by step guide, I already have a virtual network deployed within my subscription with the resources I manage. If you don’t have that yet, and you want to try this out, you will need to create a resource group and a virtual network.

Simply the deploy the following two templates:

Deploy Azure Cloud Shell Network ARM template

Deploy Azure Cloud Shell Network ARM template

You can get the Azure Container Instance OID by running the following command:

Get-AzADServicePrincipal -DisplayNameBeginsWith 'Azure Container Instance'

Also, make sure that the subnet ranges are part of the address range in your virtual network.

Reconnect Cloud Shell

If you have used Azure Cloud Shell before, you will need to reconnect that to the specific resources. You can simply run the command “cloudrive unmount” or “dismount-cloudrive”.

After that you can reconnect your Cloud Shell and select the isolated network option. Keep in mind this feature is currently in preview, and only available in West US and West Central US.

Connect Azure Cloud Shell to virtual network

Connect Azure Cloud Shell to virtual network

This will then take a moment to deploy.

Requesting a container

Requesting a container

After the Cloud Shell container is deployed within the virtual network, you can now start using private IP addresses within that virtual network or virtual networks that are peered.

SSH into Azure VM with Private IP address from Cloud Shell

SSH into Azure VM with Private IP address from Cloud Shell

I hope this blog gives you a short overview of how you can integrate Cloud Shell in your private Azure virtual network. If you have any questions, feel free to leave a comment.



Azure Architecture Best Practices Virtual Event

Azure Architecture Best Practices Virtual Event

I am happy to let you know about another free online event where I am presenting together with Microsoft Cloud Solution Architect, Dominik Zemp, about Azure Architecture Best Practices. This free virtual event will be on August 18 from 9:30am-12:00pm (CEST). In this session, you will learn about proven guidance that’s designed to help you, architect, create and implement the business and technology strategies necessary for your organization to succeed in the cloud. It provides best practices, documentation, and tools that cloud architects, IT professionals, and business decision-makers need to successfully achieve their short- and long-term objectives. We will be focusing on topics like the Cloud Adoption Framework and the new Enterprise-Scale landing zone architecture.

Azure Architecture Best Practices Virtual Event Agenda:

  • Introduction
  • Why Azure Architecture?
  • Introduction to the Cloud Adoption Framework
  • What is Enterprise-Scale?
    • Build landing zones with Enterprise-Scale
    • Critical design areas
    • Deployment using AzOps
    • Demo
  • Build on top of Enterprise-Scale – Well-Architected Framework for workloads and apps
  • Q&A

You can register for the event here: Microsoft Virtual Live Event

About the Speakers:

Dominik Zemp (Microsoft Cloud Solution Architect)

Dominik Zemp is a Cloud Solution Architect working with Global Swiss financial customers and has been working at Microsoft since 2008. Before Dominik changed role in late 2015, he worked as a Security and Identity Consultant in the Microsoft Services organization. Dominik’s focus areas are applications and infrastructure, including cloud-native applications, networking, and security. Dominik holds a Bachelor degree in IT with Specialization in software systems.

Thomas Maurer (Microsoft Senior Cloud Advocate)

Thomas works as a Senior Cloud Advocate at Microsoft. He engages with the community and customers around the world to share his knowledge and collect feedback to improve the Azure cloud platform. Prior to joining the Azure engineering team (Cloud + AI), Thomas was a Lead Architect and Microsoft MVP, to help architect, implement and promote Microsoft cloud technology. If you want to know more about Thomas, check out his blog: www.thomasmaurer.ch and Twitter: www.twitter.com/thomasmaurer

I am really looking forward to the Azure Architecture Best Practices virtual event, and I hope to see you there!

Also, check out my exam study guides to achieve the Microsoft Azure Solutions Architect Certification:



Add ISO DVD Drive to a Hyper-V VM using PowerShell

Add ISO DVD Drive to a Hyper-V VM using PowerShell

Hyper-V offers the capability to add an ISO image to a virtual CD/DVD drive and you can use Hyper-V Manager to do that, or you can also use PowerShell. Here is how you can add an ISO to a Hyper-V virtual machine (VM) using PowerShell. There are two ways of doing it if you already have a virtual DVD drive attached to the VM or if you need to add a virtual DVD drive.

This works with Hyper-V on Windows Server and on Windows 10.

Attach ISO to an existing DVD Drive on a Hyper-V VM using PowerShell

To attach an ISO file to an existing virtual DVD drive on a Hyper-V virtual machine (VM) using PowerShell, you can use the following command:

Set-VMDvdDrive -VMName Windows10 -Path "C:\Users\thoma\Downloads\ubuntu-18.04.4-live-server-amd64.iso"

Add ISO file and DVD Drive to a Hyper-V VM using PowerShell

If your Hyper-V virtual machine doesn’t have a virtual DVD drive attached to it, you can add a virtual DVD drive including the ISO file with the following PowerShell command:

Add-VMDvdDrive -VMName "Windows10" -Path "C:\Users\thoma\Downloads\ubuntu-18.04.4-live-server-amd64.iso"

If you run this command on a virtual machine, which already has a virtual DVD drive attached, you will simply add a second virtual DVD drive to this machine. You can find more information on the Add-VMDvdDrive cmdlet on Microsoft Docs.

Conclusion

If you want to build some automation around Hyper-V on Windows 10 or on Windows Server, PowerShell is the way to go. If you have any questions feel free to leave a comment.



Azure Stack Hub Partner Solutions Video Series

The Azure Stack Hub Partner Solutions Video Series

This week Tiberiu Radu (Microsoft Program Manager) and I had the chance to launch the Azure Stack Hub Partner Solutions video series. Azure Stack Hub is part of the Azure Stack portfolio, and has led the way for Microsoft’s Hybrid cloud offerings and partners have joined us to enhance the hybrid cloud journey of our customers. These partners and customers have built solutions that leverage Azure Stack Hub as part of their hybrid cloud strategy. In this video series, we explore the ways our customers and partners use, deploy, manage, and build solutions on the Azure Stack Hub platform.

Join Thomas Maurer (@ThomasMaurer) and Tiberiu Radu (@rctibi) in  this series, as we will meet customers that are deploying Azure Stack Hub for their own internal departments, partners that run managed services on behalf of their customers, and a wide range of in-between as we look at how our various partners are using Azure Stack Hub to bring the power of the cloud on-premises.

You can find more information check out Tiberiu’s blog post on Tech Community, and you can check out the first three videos:

Through August, we have quite a few partner videos following, and we will update this thread, as well as announce them on our Twitter feeds (#AzStackPartners) – follow us in this journey as we explore the partner solutions built on Azure Stack Hub!

If you want to learn more about Azure Stack and Azure Stack Hub, check out the following links:

I hope you enjoyed the blog and the videos, if you have any questions, let me know in the comments.