Virtual Machine Deployment


Course Introduction
Deploy and Migrate an SAP Landscape to Azure
13m 12s
Course Summary
3m 17s
Virtual Machine Deployment
1h 8m

After planning and researching the migration of an SAP landscape to Azure, words must become action. In Deploy and Migrate as SAP Landscape to Azure, we look at how crucial infrastructure components can be deployed and configured in preparation for migrating servers and data from "on-premises" to the Azure cloud.

This course looks at deployment and migration options and tools and services available within the Azure and broader Microsoft ecosystem that will save you time and effort. We touch on SAP-specific issues you need to be aware of and general best practices for Azure resources deployment. The Deployment and Migration course builds on Designing a Migration Strategy for SAP and Designing an Azure Infrastructure for SAP courses.

Learning Objectives

  • Understand the methods for deploying VMs and prerequisites for hosting SAP
  • Learn about ExpressRoute, Azure Load Balancer, and Accelerated networking
  • Understand how to deploy Azure resources
  • Learn about Desired State Configuration and policy compliance
  • Learn about general database and version-specific storage configuration in Azure
  • Learn about the SQL Server Migration Assistant and Azure Migration tools

Intended Audience

This course is intended for anyone looking to migrate their SAP infrastructure to Azure.


Before taking this course, we recommend you take our Designing a Migration Strategy for SAP and Designing an Azure Infrastructure for SAP courses first.


When it comes to creating or deploying the virtual machines to host your SAP system, there is one general method of creating the VM image, setting up networking with an on-premises environment, if applicable, and then configuring the machines for SAP. The main differences in how this methodology is applied is around the creation of the initial VM image. 

You can create a virtual machine manually through the Azure portal using the graphical interface wizard that walks through all the hardware, operating system, and monitoring options. This is relatively easy for a one-off exercise but would be incredibly time-consuming and error-prone for complete system deployment. You can download an Azure Resource Manager (ARM for short) template prior to creating the VM. Having said that, it's possible to download an ARM template definition for any resource at any time and use it as is or modified to create multiple instances. In fact, it isn't even necessary to download it. You can save it to a template library and deploy it from there.

ARM Templates are the preferred method for resource creation in Azure, and the Azure Marketplace is awash in pre-configured templates to use as is or modify yourself. Here we can see 81 SAP-related compute templates. Github has an extensive range of templates, with a few SAP-specific for two and three-tiered configurations.

If you are unable to find an existing image in the marketplace or GitHub that is suitable and you don't want to create one from scratch, you can deploy a VM from an image of one of your own virtual machines. One small caveat is that you need to take into account the hardware key calculation for SAP licenses and abstract or parametrize information like hostname and ID for Windows machines. You can create an image from an existing VM through the portal by clicking the Capture on the VM home page. This takes you through to a wizard where you can select or create an image gallery to store the VM image. Creating an image from a VM will render that machine unusable. Once created, an image will appear in your image gallery. An image can have multiple versions, and a VM can be created directly from the gallery. 

A VM image can also be created using a few PowerShell commands. Firstly, you must deallocate the VM with Stop-AzVM and set the status of the VM to Generalized with Set-AzVM. Next, assign the virtual machine to a variable and use the id of the VM to create an image configuration with New-AzImageConfig. Finally, make the image with New-AzImage. It's possible to deploy up to 20 virtual machines concurrently from a single image.

You can upload a VHD that contains the operating system with SAP and database binaries, as well as VHDs with the DBMS data and logs files. As this scenario is most often associated with a hybrid environment where the SAP system spans Azure and on-premises, there is no need to worry about machine hostnames and SIDs as the VM is still part of the on-premises network – just located somewhere else.  However, this deployment method will not automatically install the VM Agent, so it will need to be manually installed along with the Azure Extension for SAP if you are running SAP NetWeaver. For Windows Server, download and install the Azure VM Agent MSI installer package. From SUSE Linux, install WALinuxAgent with zypper, and for Red Hat and Oracle Linux, install the agent with yum.

SAP systems have special requirements like the ability to monitor the physical computer that hosts the virtual machines. To this end, the Azure Extension for SAP must be installed to send host data to SAPOSCOL and SAP Host Agent. Currently, there are two versions of the Azure VM extension for SAP, imaginatively name the default and new versions. However, the New extension is currently only recommended for use in the following specific circumstances.

  • Installing the extension with Terraform
  • Installing the extension with ARM templates
  • When not installing the extension with the Azure CLI or Azure PowerShell
  • Installing the extension on SUSE Linux Enterprise Server  version 15 or greater
  • When Microsoft or SAP support asks you to use the new extension.
  • Or Using Azure Ultra Disks or Standard Managed Disks

First, to install the new extension, make sure that the old or default extension is not installed; the two cannot co-exist on the same VM. Ensure that you are running SAP Host Agent 7.21 PL 47 or greater and that the latest version of Azure PowerShell is installed or Azure command-line interface 2.0 is installed.

The new extension relies on a managed identity assigned to the virtual machine to access the necessary VM data, so before beginning the extension installation, create the identity and assign it to the VM, granting it permission to access all resources, such as disks and NICs, that are associated with the VM.

To install with PowerShell, we want to set the VMAEM extension. We can see available extensions by listing them with Get-Command, much as you would list files with ls or dir. We also need an environment, which we can also list with Get-AzEnvironment, although there are currently only 4. We get the environment by name and store it in a variable. Then we set the context with Set-AzContext and our subscription name. Finally, we install the extension with Set-AzVMAEMExtension using the resource group and VM name as parameters with the InstallNewExtension option. The global Azure environment is AzureCloud, while Azure China 21Vianet is AzureChinaCloud.

Installing the new extension with Azure CLI follows a slightly different path and syntax. First, set up the identity, then store the identity and resource group ids in variables for later use when assigning the reader role. Finally, set the extension on the virtual machine.

Installing the current or default extension is the same procedure using PowerShell, except that you omit the -InstallNewExtension option from the Set-AzVMAEMExtension command. Installing the default extension with Azure CLI involves different commands, and you can install it with classic Azure CLI as well as CLI 2.0. Installing with Azure CLI 2.0 consists of logging in and adding the extension with az extension add and then setting the aem extension on the virtual machine. 

You can run a readiness check to make sure a VM is able to provide the supporting data to SAP. For the default extension version on a Windows machine, open a command prompt – it isn't necessary to do this as admin. CD into the extension directory, where the version portion of the path may vary. If there are multiple version folders, you can check the AzureEnhancedMonitoring service's path to the executable for the correct one. Once in the appropriate directory, run the azperflib.exe executable without parameters. The program runs in a 60-second loop, reporting a list of performance counters. You are looking for a health and diagnostic status of OK. Azperflib.exe is terminated simply by closing the command prompt. If azperflib returns errors, check that extension is installed correctly and that the service is running.

To perform the default readiness, check on a Linux box, SSH into the VM, and run the following commands. PerfCounters to see a list of performance counters where there should only be one line with the words 'Error' and 'none.' Followed by the LastErrorRecord command, which should return nothing.


About the Author
Learning Paths

Hallam is a software architect with over 20 years experience across a wide range of industries. He began his software career as a  Delphi/Interbase disciple but changed his allegiance to Microsoft with its deep and broad ecosystem. While Hallam has designed and crafted custom software utilizing web, mobile and desktop technologies, good quality reliable data is the key to a successful solution. The challenge of quickly turning data into useful information for digestion by humans and machines has led Hallam to specialize in database design and process automation. Showing customers how leverage new technology to change and improve their business processes is one of the key drivers keeping Hallam coming back to the keyboard.