Customize a Linux virtual machine on Azure

SUSE Linux Enterprise Server (SLES) is an adaptable and easy-to-manage platform that allows developers and administrators to deploy business-critical workloads on-premises, in the cloud and at the edge. It is optimized for performance, security, and reliability. Since 2009, SUSE and Microsoft have been working together to provide unique, codeveloped, Azure-optimized solutions for SUSE SLES.

Example scenario

Imagine you work for a startup retailer that wants to create a website, and you have been asked to set up a LAMP stack (Linux OS, Apache webserver, MySQL database, PHP programming) using SUSE SLES on Azure.

What will we be doing?

Through the course of this post, we’ll discuss two tools that are unique to SUSE and how you can use them to add packages to your SUSE SLES VM on Azure.

What is the main goal?

By the end of this post, you will be able to deploy a SUSE Linux VM on Azure, install packages with YaST, and reconcile dependencies with zypper.

 

A virtual machine (VM) on Azure provides the infrastructure for running your workloads. Recall that your employer needs you to create a new VM for the LAMP stack. Here we will use the Azure portal to create the new VM. The portal walks you through the required information and provides hints and helpful messages during the creation.

  1. Sign in to the Azure portal
  2. On the Azure portal menu or from the Home page, under Azure services, select Virtual machines. Alternatively, you can enter Virtual machines in the top search box, and press Enter to get the virtual pane.
  3. In the top menu bar, select Add > Virtual machine. The Create a virtual machine pane appears.
  4. In the Basics tab:
    • Choose the subscription you will be using for this exercise and Resource group and name it rg-lamp-demo
    • Name your virtual machine vm-lamp-test-1 and select the default Availability option
    • Choose the SUSE Enterprise Linux 15 SP2 + Patching option for your image
    • Leave the Azure Spot instance box unchecked
    • Choose the smallest size VM (Standard_B1s)
    • Select the SSH public key for your authentication type
    • Generate a new key pair and store it on your local machine along with the username
    • Press next to customize your VM, or press Review + create to deploy your SLES VM
  5. Select the default options for the Disks and Networking settings
  6. Finish configuring the VM and creating the image by selecting Review + create.
  7. After the system validates your options, and gives you details about the VM being created, select Create to create and deploy the VM. The Azure dashboard will show the VM that’s being deployed. This may take several minutes.
  8. From the Azure portal, select Go to resource and the Overview pane to see the VM you just created
  9. Open the connect menu and choose ssh
  10. Follow the steps to connect your machine with ssh. If you are using a local Windows machine, you will need putty, Windows Subsystem for Linux (WSL), or another software that provides ssh under Windows. If you are using a local Linux machine, open a terminal.launch-virtual-machine

 

YaST is an admin tool developed by SUSE that allows you to add packages to your machine (in addition to other things).

Once you’ve launched a pay-as-you-go SLES virtual machine image on Azure, you need to add packages for the Apache, MySQL, and PHP portion of the LAMP stack to build your website.

In this unit we’ll talk about what packages are, and how you can use YaST to manage them on your SLES virtual machine.

Packages add functionality to your machine

Your Linux engine is a blank slate that you need to fill to create the functionality and feature set you desire. This requires installing software. Many times, software packages are developed by individual contributors from the open-source community, which means that they don’t always work well together.

Distributors like SUSE provide bug fixes, maintenance and support of such packages and provide them as a “Linux Distribution” to give you ready-to-run options. The main SUSE distribution targeted to enterprise customers is the SUSE Linux Enterprise Server (SLES). There is also an open-source version called openSUSE.

SUSE uses the RPM package format to deliver such software to the system.

By choosing to run SLES, you automatically get access to over 3,500 RPM packages that have been pre-configured by SUSE engineers to work great together.

YaST is a specialized tool that helps you to administrate your system

YaST is a SUSE Linux Enterprise Server tool that provides a graphical interface for all essential installation and system configuration tasks. Whether you need to update packages, configure a printer, modify firewall settings, set up an FTP server, or partition a hard disk—you can do it using YaST. In this post, we’ll be using YaST to add packages to your VM. Following similar steps you can use YaST to update and delete packages as well.

Since all VMs in Azure are remote, you will not have a graphical environment to start and will only be able to log into the system over ssh. You will need load YaST using the sudo command, which allows you to perform administer-level functions from your unique log-in without using the administrator log-in ID. This distinction is important because it allows for better activity tracking and auditing.

YaST has two graphical interfaces: one for use with graphical desktop environments like KDE and GNOME and one that is an ncurses-based, pseudo-graphical interface for use on systems without an X server.image-yast-control-center-graphical-interface-inline

 

yast-control-center-text-interface-inline

The ncurses-based, pseudo-graphical YaST interface is designed primarily to help system administrators to manage systems without an X server. The interface offers several advantages compared to the conventional GUI:

  • You can navigate the ncurses interface using the keyboard, and there are keyboard shortcuts for practically all interface elements.
  • The ncurses interface is light on resources, and runs fast even on modest hardware.
  • You can run the ncurses-based version of YaST via an SSH connection, so you can administer remote systems.

Keep in mind that the minimum supported size of the terminal emulator in which to run YaST is 80×25 characters.

Note that when you first start YaST, not all of the functionality may automatically install. If you appear to be missing something, you can try searching for available packages with “YaST” in the name.

Packages are cumulative and most frequently used as collections

By nature, packages are cumulative and have defined dependencies that lead to specific outcomes. For example, if you want to run a relational database like MariaDB, you need to install the collection of packages, called a module, that enables MariaDB.

SUSE makes it easier to find the right packages for the tasks you want to complete by offering several different groupings of related packages in YaST.

  • Modules group packages in like bundles i.e. Programming languages, Public Cloud adoption
  • Patterns group packages by popular scenarios i.e. Run Oracle workloads, Enable a graphical interface
  • The repository is like a directory that show packages across the entire server

You can view these different options through the TUI or GUI interface for YaST.

 

Zypper is a command-line package manager that automatically reconciles package dependencies.

With Apache webserver installed, it’s time to add MySQL database to your PAYG instance of SLES on Azure.

In this unit, we’ll talk about how SUSE handles package dependencies and explain what zypper package manager is and how to use it for installation.

Packages alert you of dependencies…One. At. A. Time.

While individual packages can alert you to dependencies on other packages for defined activities or modules, these alerts are raised at the package level, meaning dependencies are triggered one at a time. You must manually select the next package before another dependency is surfaced, which triggers another package that you must select, and so on. For modules with many packages, adding a complete set of packages using this method can take a long time.

SUSE’s package manager, zypper, reconciles package dependencies

SUSE created zypper, a command-line package manager, which makes use of libzpp (SAT solver) to reconcile package dependencies for you. With zypper, all related packages are flagged at once when you select an activity or grouping, so you can install, update, or delete them with a single command. The YaST GUI and TUI includes zypper built into it. YaST runs zypper automatically in the background every time you start. Compared to manually finding and selecting package dependencies through RPM, zypper saves time.

Packages and corresponding modules configuration are updated

As soon as SUSE becomes aware of an error within a package, an update package is shipped. If you run PAYG, the updated packages are pushed out to a SUSE update infrastructure at your Azure datacenter location and on to your machine when you connect. If you run BYOS, you can download the updates through SUSE directly.

You can manually pull updates using zypper

The difference between a patch and an update is that a patch contains one or more packages and an update is always a single package. You can add additional parameters for the update or patch. , you can only install security fixes by selecting–category security.

Let’s have a look at some basic zypper examples:

  • List available repositories where packages come with sudo zypper lr or sudo zypper repos.
  • List available patches with sudo zypper lp or sudo zypper list-patches.
  • List available updates with sudo zypper lu or sudo zypper list-updates.
  • Install updates/patches with sudo zypper upsudo zypper update, or sudo zypper patch.

Command line vs. GUI (zypper vs. YaST)

You might be wondering why did we use YaST to load apache and now we’re using zypper to add mariadb? Does it matter which one I use? The short answer is no. Zypper and YaST do the same things, they just go about it a little differently.

From command line, you can launch YaST and get a graphical menu that shows you all the different options you can use to administrate your system. Most of the time, graphical systems are preferred because they provide a visual overview of commands, so you don’t need to remember everything.

Zypper’s command-line interface is faster because you don’t have to navigate several windows or menu bars to execute the command. It also allows you to create your own workflow (or script) which is not possible in a graphical environment. If you use the commands and parameters regularly, zypper can be a faster way to get things done.

 

In the scenario for this post, the startup retailer you work for wanted to create a new website with a LAMP stack.

Through the units in the post, we discussed how to create a SUSE SLES VM on Azure through the Azure portal, add Apache webserver using YaST, and add MariaDB with zypper.

The purpose of this post was to communicate the role RPM packages play in customizing your virtual machine in the cloud and to introduce you to SUSE tools that make installing packages and managing package updates easier and more automated.

Learn: WordPress hosting Australia

Once you become familiar with YaST and zypper, you can use them to customize and refine other SUSE deployments on Azure such as:

  • SLES for SAP Applications, which includes specialized, built-in features to reduce downtime, enhance security, optimize performance, and reduce the maintenance workload of sys admins.
  • SLES for High Performance Computing (HPC), which includes infrastructure and tools to support parallel computation in the cloud.
  • Others available on Azure Marketplace: SUMa, SQL on SLES, SAP Solution Templates

How to Set up Azure development environment for App Dev

Azure development environment

The Eclipse integrated development environment is a popular tool for Java development. It’s also a great choice for connecting your Java applications to Azure; the Azure Toolkit for Eclipse provides templates and features to streamline Azure integration with your Java applications.

Eclipse

Eclipse is one of the most widely used Java IDEs. It is also a versatile development environment, featuring an extensible plugin architecture that can be used to support languages other than Java. While most Eclipse users are Java developers, Eclipse can also be used to build applications with C++, Python, C, and Ruby.

Eclipse is supported on Windows, macOS, and Linux. The installation process uses the Eclipse installer on all platforms, with few differences in installation procedures between the platforms.

Installing Eclipse for Java or Java EE on any platform is straightforward. The installer will prompt you to choose the packages to install depending on the target language and frameworks.

Azure Toolkit for Eclipse

The Azure Toolkit for Eclipse provides templates and functionality that you can use to easily create, develop, test, and deploy cloud applications to Azure from Eclipse. The Azure Toolkit is open source, actively developed, and hosted in GitHub.

The toolkit includes integration templates for Docker containers, HDInsights, Azure documentation, Azure Cache for Redis, storage account operations, and virtual machine management.

 

The Azure Toolkit is installed through the Eclipse IDE itself; it’s the same procedure on all the supported operating systems. The toolkit is available from the Eclipse Marketplace.

The IntelliJ IDEA is a popular IDE for Java development. It’s also a great choice for connecting your Java applications to Azure; the Azure Toolkit for IntelliJ provides templates and features to streamline Azure integration with your Java applications.

IntelliJ IDEA

IntelliJ IDEA is one of the most widely used Java IDEs. It is also a versatile development environment, featuring an extensible plugin architecture that can be used to support languages other than Java. While designed as a Java IDE, IntelliJ IDEA can also be used to build applications with JavaScript, Scala, Ruby, etc.

IntelliJ IDEA is supported on Windows, macOS, and Linux. The installation process uses the IntelliJ IDEA installer on all platforms, with few differences in installation procedures between the platforms.

Installing IntelliJ IDEA for Java or Java EE on any platform is straightforward. The installer will prompt you to choose the packages to install depending on the target language and frameworks.

Azure Toolkit for IntelliJ

The Azure Toolkit for IntelliJ provides templates and functionality that you can use to easily create, develop, test, and deploy cloud applications to Azure or any managed hosting from IntelliJ IDEA. The Azure Toolkit is open source, actively developed, and hosted in GitHub.

The toolkit includes integration templates for Docker containers, HDInsights, Azure documentation, Azure Cache for Redis, storage account operations, and virtual machine management.

The Azure Toolkit is installed through the IntelliJ IDEA itself; it’s the same procedure on all the supported operating systems. The toolkit is available from the IntelliJ IDEA Marketplace.

Visual Studio Code is a popular choice for developing applications for Azure. It’s lightweight, taking up only megabytes of storage space, and works on Windows, Linux, and macOS.

Visual Studio Code

Visual Studio Code is a free source code editor developed by Microsoft. It supports hundreds of programming languages, includes Git integration, and is designed to connect to Azure cloud services.

However, Visual Studio Code doesn’t include a compiler. Code compilation for specific languages and scenarios is added via extensions.

Extension model

One of the most powerful features of Visual Studio Code is the extension model. Extensions extend the capabilities of Visual Studio Code to add a wide range of new capabilities. For example, extensions can be used to add compilers, add spell checking, and integrate with Azure services.

Extensions are free and can be added from the Extensions page within Visual Studio Code. You can explore the available extensions in the Visual Studio Code Marketplace.

Azure extensions

Many of the extensions target Azure features and products. For example, there are extensions that provide features such as Docker support, subscription management, tooling for the Azure CLI, database access, and Azure Storage API integration.

Install Visual Studio Code and prepare for Azure development

Visual Studio Code supports Windows, Linux, and macOS. To install Visual Studio Code, go to https://code.visualstudio.com/.

Visual Studio is a full featured integrated development environment (IDE) for a wide range of programming application types and languages. Visual Studio has a full set of tools and features that are specifically targeted at developing applications with Microsoft Azure. These features provide support for Azure development, debugging, and deployment tools that are tightly integrated with the IDE.

Visual Studio

Visual Studio is a fully featured IDE used to develop applications for a wide range of application types in including Windows, Android, iOS, web, and Azure.

When installing Visual Studio, you’ll see that several workloads are available. Workloads are collections of libraries and components that define an area of functionality that can be installed. Instead of installing an individual component where you must know and remember the dependencies between each, you can use workloads to do “themed” installations. Visual Studio workloads ensure that all necessary components are included.

 

The base installation of Visual Studio comes with no tools or libraries for Azure development. For that, you’ll need to include the Azure development workload, which includes the Azure SDKs, tooling, and template projects.

To install Visual Studio, download the installer. The installer will ask which workloads to install; you’ll specify the Azure development workload. Additional functionality is typically added via NuGet packages or Visual Studio extensions.

Visual Studio for Mac

Visual Studio for Mac is a natively designed and developed IDE for macOS. It lets you build solutions for mobile apps on Android and iOS, the web, and .NET Core.

The base installation of Visual Studio for Mac comes with contextual integration of Azure tooling. For example, if you are building a Xamarin app for Android, then the included Connected Services template will provide a link to create a mobile back end with Azure App Service. If you want to create an Azure function, there is a project template under the Cloud category.

If you require tools for Azure features and functions that aren’t in the base installation, you’ll likely need to add NuGet package or a Visual Studio for Mac extension.

 

To install Visual Studio for Mac, download the installer. The installer will inspect your system to determine what components are required, and whether any components need to be updated.

Implement Azure Cloud Policy

Group Policies, or GPOs, have been used by Windows server administrators for a long time, to manage security, provide consistency across the Windows Server environment in your organization. Some examples of group policies are enforcement of password complexity, mapping shared network drives and configuring networked printers.

Azure cloud hosting offers similar features in Azure Resource Manager using Azure cloud policy. A policy provides a level of governance over your Azure subscriptions. Policy can enforce rules and controls over your Azure resources. Some examples of how you might use this include limiting the regions you can deploy a resource to, enforcing naming standards, or controlling resource sizes. Azure provides many example policies that you can use or you can define custom policies using JSON.

 

Policies are assigned to a specific scope, which could be a management group (a group of subscriptions that are managed together), a subscription, a resource group, or even an individual resource. Most commonly policy will be applied at the subscription or resource group level. Individual policies can be grouped using a structure known as initiatives, which are sometimes called policy sets. Policies have a scope of assignment that can be defined at the individual resource, the resource group, the subscription, or a management group (a group of subscriptions managed together), or all of the subscriptions in a given tenant.

Another example of how you might implement Azure cloud hosting Policy is tagging of resources. Azure tags, which are described below, store metadata about Azure cloud resources in key-value pairs, and are commonly used to highlight environment type (test, QA, or production) or cost center for a given resource. A policy that required all resources to have a tag for environment and cost center would cause an error and block the deployment of any Azure cloud resource that did not have the required tags.