Tag: Linux

Azure CLIInfrastructureOpen Source

Azure CLI 1.0 vs 2.0 Compared, Installation and Usage

The Azure CLI is the cross-platform, command-line tool for managing resources in Microsoft Azure. Microsoft recently released the Azure CLI 2.0 and the commands start with “az” instead of “azure” like Azure CLI 1.0. This article runs through the main differences between Azure CLI 1.0 and Azure CLI 2.0 to help you understand how to use each one.

Installation and Platform

When the Azure CLI 1.0 was first released it was call the X-Plat CLI, and offered a new cross-platform command-line tool to use for Azure automation tasks. It offered an alternative to the Azure PowerShell cmdlets that gave a command-line tool for use on macOS and Linux, in addition to Windows. In the early days it was built on top of the Azure Service Management API’s, and has since been migrated over to support the newer Azure Resource Management API’s.

The new Azure CLI 2.0 was built with Azure Resource Management (ARM) from the start. It was also built with the lessons learned from 1.0 in mind to make 2.0 a better cross-platform, command-line tool. The development platform and language used to build the Azure CLI 2.0 was changed, and the commands essentially changed a bit in the process. It’s really not an “in-place” migration, and requires you to understand a little more than to just install the new version.

The Azure CLI 1.0 was written with Node.js to achieve cross-platform capabilities, and the new Azure CLI 2.0 is written in Python to offer better cross-platform capabilities. Both are Open Source and available on Github.

Azure CLI 2.0 is written in Python, Azure CLI was written in JavaScript. Both are Open Source!

Here’s the platform differences between the 2 version of the Azure CLI along with links where you can find the Open Source repository for each:

Azure CLI 1.0

Azure CLI 2.0

Azure CLI Installation

Since the Azure CLI is cross-platform it can be installed on Windows, macOS, and Linux. This is true for both the Azure CLI 1.0 and Azure CLI 2.0. Since the Azure CLI 1.0 is written with Node.js, it will require Node.js to be installed on your machine. While the Azure CLI 2.0 is written in Python, and requires Python.

Azure CLI 1.0 Installation

Here’s commands to install Azure CLI 1.0 at the command-line using Node.js:

sudo npm install -g azure-cli

Use a Docker Container to run the Azure CLI 1.0:

docker run -it microsoft/azure-cli

You can also use an installer with Windows and macOS to install the Azure CLI 1.0 more easily as well. You can find the installers for the Azure CLI 1.0 on the Github repository.

Azure CLI 2.0 Installation

Here’s commands to install Azure CLI 2.0 on different platforms. Keep in mind that it does require Python.

Windows Command-Line

You can download the .MSI installer for Azure CLI 2.0 to install the Windows command-line support for Azure CLI.

Bash on Windows 10

The Ubuntu Bash on Windows 10 can be used to run the Azure CLI 2.0 while utilizing it’s full support for Bash and on a Windows 10 machine at the same time.

  1. First step, if you don’t have Bash on Windows installed (Ubuntu Bash on Windows 10, or the newer (coming soon) support for SUSE and Fedora on Windows 10 too!) then install it!
  2. Using Bash, modify your sources list:
    echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ wheezy main" | \
    sudo tee /etc/apt/sources.list.d/azure-cli.list
    

Run the following sudo commands to install the Azure CLI 2.0:

sudo apt-key adv --keyserver packages.microsoft.com --recv-keys 417A0893
sudo apt-get install apt-transport-https
sudo apt-get update && sudo apt-get install azure-cli

macOS and Linux
Here’s the installation command to install the Azure CLI 2.0 on macOS as well as Linux using Curl:


curl -L https://aka.ms/InstallAzureCli | bash

Additionally, you may need to restart your command-lim in order for some changes to take affect. You can do this with the following command:


exec -l $SHELL

Docker Container

You can also run the Azure CLI 2.0 in a Docker Container fairly easily. Here’s the “docker run” command to do this:


docker run azuresdk/azure-cli-python:<version>

apt-get on Linux

You can also use the following commands to install Azure CLI 2.0 on Linux using apt-get.

On 32-bit systems:


echo "deb https://packages.microsoft.com/repos/azure-cli/ wheezy main" | \
sudo tee /etc/apt/sources.list.d/azure-cli.list

On 64-bit systems:


echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ wheezy main" | \
sudo tee /etc/apt/sources.list.d/azure-cli.list

After you run the above 32-bit or 64-bit specific command, then you’ll need to run the following sudo commands as well:


sudo apt-key adv --keyserver packages.microsoft.com --recv-keys 417A0893
sudo apt-get install apt-transport-https
sudo apt-get update && sudo apt-get install azure-cli

There is some further documentation for installing the Azure CLI 2.0 available in the Azure Documentation site.

Getting Started with Azure CLI Commands

Both the Azure CLI 1.0 and 2.0 have very similar commands. However, the command start differently. With the Azure CLI 1.0 commands start with “azure” and with the Azure CLI 2.0 command start with “az”.

Before you can go about running Azure CLI commands, you need to first login to your Azure Subscription. Here are commands to do this in both Azure CLI versions:


# Azure CLI 1.0

azure login

#Azure CLI 2.0

az login

To get a full list of the available commands and full help information you can run the following command:


# Azure CLI 1.0

azure

# Azure CLI 2.0

az

Also, you can find the version of Azure CLI you have installed by using the following command:


# Azure CLI 1.0

azure --version

# Azure CLI 2.0

az --version

Azure CLI Command Examples

Here’s some example commands using both the Azure CLI 1.0 and Azure CLI 2.0. You can see that they aren’t really all that different outside of the trigger command of either “azure” or “az”.

Create New Azure Resource Group


# Azure CLI 1.0

azure group create --name MyGroup1 --location eastus

# Azure CLI 2.0

az group create --name MyGroup1 --location eastus

Create Azure App Service Plan


# Azure CLI 1.0

azure appserviceplan create --name MyPlan --resource-group MyGroup1 --location eastus --sku F1

# Azure CLI 2.0

az appservice plan create --name MyPlan --resource-group MyGroup1 --location eastus --sku F1

List All Azure Virtual Machines


# Azure CLI 1.0

azure vm list

# Azure CLI 2.0

az vm list

More Information

You can find much more information about using the Azure CLI 1.0 and 2.0 in the documentation on the Open Source project sites hosted on Github, and in the Microsoft Azure documentation. Here’s some link to those resources:

Also, don’t forget to try out the new Azure Cloud Shell to use bash with both the Azure CLI 1.0 and Azure CLI 2.0 command directly in the Azure Portal from anywhere!

Happy cross-platform, command-line scripting in the cloud!!

CertificationOpen Source

LFCS: Linux Foundation Certified System Administrator Certification

The Linux Foundation Certified System Administrator (LFCS) certification from The Linux Foundation is a full Linux certification for verifying and validating your Linux Operating System skills. Linux is the #1 operating system for web servers, cloud computing, smartphones and consumer electronics. It’s been growing very rapidly over the years, and even Microsoft has fully embraced Linux for running workloads in the Microsoft Azure cloud.

The IT industry is increasingly seeking out IT Professionals who have Linux Operating System management and administration skills. This certification will help you validate those skills to help advance your career. Read More

DevelopmentVideo

Intro to Azure for Developers FREE Webinar On-Demand from Opsgility

The other day I hosted a FREE Webinar with Opsgility that provides an Introduction to Azure for Developers. In this webinar I went over an introduction to what IaaS, PaaS, and SaaS are. Then I dove into the Azure Portal and showed how to create IaaS (Infrastructure as a Service) VMs with Windows and Linux, as well as how to remote into those VMs with Remote Desktop and SSH; respectively. I also went into deploying a Web Application into an Azure Web App PaaS (Platform as a Service) service directly from within the Visual Studio IDE, and I even showed how you can easily deploy a website directly from Github into an Azure Web App as well! I also discussed Azure SQL Database (“Database as a Service”), as well as a few additional services and features.

I encourage you to watch the entire webinar recording to see the whole demo of everything. There are very little slides, and the webinar was almost entirely demos of real features, real functionality, and real Azure usage! Go watch! Read More

InfrastructureVideo

Create Ubuntu Linux VM in the Azure Portal

This is a short video that shows how to create an Ubuntu Linux Virtual Machine (VM) in the Microsoft Azure Management Portal. It also explains a few details on how VMs are hosted in Azure, along with a demo on how to connect to the Ubuntu Linux VM using ssh and bash.

Please, subscribe to get more videos like this all around Microsoft Azure.

This is one of the first videos I’ve published to the Build Azure YouTube Channel where I’m starting to build out video content to accompany this site. Enjoy!

HardwareInfrastructure

Windows Server running on ARM CPUs, Azure is Next!

So far the servers within Microsoft Azure data centers have been running Intel processors (CPUs). For a long time I’ve wondered if the power efficiency of ARM CPUs could make them more cost effective than Intel x64 CPUs that are more powerful. It’s possible through the use of parallel computing that distributing load across many more ARM CPU cores that consumer lower power could be more cost effective than distributing the same load across fewer more powerful Intel CPUs. Since I first came up with the idea, I’ve assumed that ARM would be more cost effective, however, I haven’t seen anything to back it up. With recent news about Microsoft exploring Windows Server running on ARM, and ARM based cloud server, it looks like they’re dedicating some serious money to this very research effort.

ARM has already revolutionized mobile devices and Internet of Things (IoT). Could the next step for ARM CPUs be to revolutionize the Cloud and server market? Read More

DevelopmentInfrastructure

Visual Studio 2017 Development using a VM in Azure

screen-shot-2017-03-04-at-10-43-14-amIn the past the only option for writing code and building software using Visual Studio was to install it on your local machine. With technologies like Windows Hyper-V and VMWare things became less invasive by allowing you to develop software inside of a Virtual Machine (VM). With the cloud, things have become even easier. You can now easily, spin up a Virtual Machine in Microsoft Azure, use it for what ever you need, then shut it down or delete it when it’s no longer needed. This can be an extremely valuable tool for any software developer; especially when you might need multiple development environment configurations on a regular basis. This article helps you navigate the benefits as well as the process of utilizing Microsoft Azure to host multiple development machines running Visual Studio 2017 in the cloud.

Developing in the Cloud

It can sound a little mysterious to develop for the cloud, in the cloud. But using a VM as a development machine is pretty much just that. By using Virtual Machines as your development machines and environments it allows you to scale your local PC much further than it’s local hardware could ever scale. You can add more CPU power, more memory, more storage space. VM’s are a simple extension to the local constraints of your local PC. Plus, your local PC can be running any OS (Windows 10, macOS, Linux, or even iOS!)

The trick to using a Virtual Machine (VM) running Visual Studio for development, is to have a Remote Desktop Client application installed. Microsoft Remote Desktop (RDP) is a set of functionality and protocol that let’s you “remote in” to any Windows machine (either physical or virtual) and use it just like you were sitting at the machine directly. This let’s you use pretty much any computer remotely, and grants tons of power to any developer especially within the Microsoft Azure Cloud.

The steps to developing in the clouds are essentially as follows:

  1. Have a Microsoft Remote Desktop client application installed on your local computer; no matter the operating system.
  2. Setup 1 or more Virtual Machines (VMs) in the Cloud.
  3. Use the Microsoft Remote Desktop client to connect to and use those VMs just like they are your local computer.

Of course there are a few more things to know about using a VM to host Visual Studio and build software for the cloud, in the cloud. The rest of this article will walk through everything you need to know to setup Visual Studio VMs in Microsoft Azure, and get building software not just for the cloud, but also in the cloud today!

Benefits of Development VMs

Most developers focus mostly on the Platform as a Service (PaaS) services in Microsoft Azure, such as: Web Apps, Blob Storage, SQL Database and Service Bus. However, many Developers may not be very familiar with the Virtual Machine (VM) capabilities of Azure that includes the ability to easily spin up a Windows VM with Visual Studio already installed.

There are a few VM images available in the Azure Marketplace that have Visual Studio pre-installed. These are great way to get started with creating a temporary, or even longer term use, Development VM much quicker than installing the Operating System and Tooling yourself. (hint: It takes awhile to install Visual Studio)

Before we get into the different Visual Studio VMs available in the Azure Marketplace, let’s first cover some of the biggest benefits of spinning up a pre-built, pre-configured Windows VM with Visual Studio pre-installed.

  1. Zero Install Required – You can spin up a new Visual Studio development VM in a matter of minutes, and the best part is that you don’t have to install Windows or Visual Studio yourself.
  2. Protected from Hardware Failure – Using an Azure VM for development, or any other work use, provides isolation against hardware failures locally that involve your laptop, desktop, or external storage.
  3. Easily “Add” CPU / Memory Resources – Not only does an Azure VM allow you to essentially extend the capabilities of your laptop or desktop into the Cloud, but you can also resize the VM anytime to add or remove CPU Cores and Memory as needed.
  4. Device Agnostic – Azure VM’s can be connected to with Remote Desktop from any Computer, such as Windows, Linux, macOS, or even tablets! This allows you to easily interchange which physical “computer” you use for your development.

As you can imagine there are many benefits and advantages to using a VM for development, and putting that VM in the Cloud, in Microsoft Azure, further enhances those benefits to new levels. The previous mentioned benefits are only a few of the most obvious benefits. I’m sure once you start embracing Azure VMs for development that you’ll realize additional benefits as well.

Available Visual Studio 2017 VMs

For the IT Pro folks it’s known that the Microsoft Azure Marketplace offers many different Windows Server and Linux VMs that can be easily provisioned in minutes. However, many IT Pros and Developer alike may not be aware that the Microsoft Azure Marketplace also contains pre-build images for both Windows Server and Windows 10 with Visual Studio pre-installed.

Here’s the list of the different Visual Studio 2017 Virtual Machine images available in the Azure Marketplace:

  • Visual Studio Community 2017 on Windows Server 2016
  • Visual Studio Community 2017 on Windows 10 Enterprise N
  • Visual Studio Enterprise 2017 on Windows Server 2016
  • Visual Studio Enterprise 2017 on Windows 10 Enterprise N

vs17-azuremarketplace-images-rc

As you can see there are Visual Studio VM images for both the Free Community edition, as well as the Enterprise edition, as well as Windows Server 2016 and Windows 10 Enterprise. However, the specific VM images you will see available within your Azure Subscription will depend on what type of Azure Subscription you have. If you have an MSDN Azure Subscription you will see the list as shown above. If you have a different type of Azure Subscription you will not see the Windows 10 based Visual Studio VMs as Windows 10 desktop operating system is not available through the Azure Marketplace without an MSDN Subscription.

Can you Bring Your Own VM (BYOVM)?

An interesting question that comes up, especially with the fact that Windows 10 VMs aren’t generally available to all Azure Subscriptions, is: Can you bring you own custom VM to Azure?

The short answer: YES!!

The long answer: You can build a VM locally using either Hyper-V or VMWare. Then you can upload that VMs .vhd operating system disk image into Azure Blob Storage. For VMWare, you’ll need to first convert it to a .vhd. Also, the newer Hyper-V .vhdx format isn’t supported in Microsoft Azure at this time, so those need to be converted to .vhd as well. After uploading the VM image, you can then setup an Azure VM to use your custom uploaded .vhd disk to boot from, and then you’ll have a custom built VM running in Azure.

With this method you can setup and install anything you need / want, so long as you provide all the necessary licensing required to run the software and it’ll host just fine in Microsoft Azure. It’s worth noting that this method takes far longer to get setup and you generally want to use a pre-built, pre-defined VM image from the Azure Marketplace if you can.

Provision a Visual Studio VM

The most obvious requirement to provisioning a Visual Studio Virtual Machine in Azure is that you’ll need to have an Azure Subscription. Also, as previously described, the available Visual Studio VM images in the Azure Marketplace will vary depending on the type of Azure Subscription that you have.

To help guide you through the process of provisioning a new Visual Studio VM in Azure, you can follow these simple steps:

  1. Navigate to the Azure Portal (http://portal.azure.com) and login
  2. Click on the green +New button in the left hand navigation of the Azure Portal, then type Visual Studio 2017 into the Search the marketplace textbook, and press Enter.
    vs17-azureportal-new
  3. On the Everything search results, click on the desired Visual Studio VM image you would like to provision.
    vs17-azureportal-search-rc
  4. On the VM information blade, click the Create button to get started provisioning. Be sure to leave the Deployment Model dropdown to the default of Resource Manager.
    vs17-azureportal-winservercommunity-rcNote: in these screenshots I chose to use the Visual studio Community 2017 on Windows Server 2016 marketplace image.
  5. On the Create virtual machine – Basics blade, fill out the necessary fields to define the basic settings for the VM, then click OK.
    • Name: the name of your VM
    • User name and Password: the Admin login credentials for the VM
    • Resource group: the Azure Resource Group to place the VM and all it’s resources into. This is just a way for you to more easily organize resources within the Azure cloud.
    • Location: this specifies the Azure Region to host your VM in. Generally you want to set this to the nearest region to where you are located geographically to help reduce internet latency when connecting to the VM.
      vs17-azureportal-basics-rc
  6. On the Create virtual machine – Choose a size blade, choose the VM Instance Size to use for the VM, then click Select. This is what defines the CPU Core count and amount of Memory that will be available to the server. I would recommend you normally use the DS2_V2 size which will give you 2 CPU Cores and 7 GB Memory. A smaller size will generally be too small and have poor performance. Alternatively, you can click on the View all link to list our ALL the available VM sizes so you can choose a different one if desired.
    vs17-azureportal-new-choosesize
  7. On the Create virtual machine – Settings blade you can configure more advanced networking configurations for the VM is necessary. If you’re unsure what to do, then just leave the default values as they are, and click OK.
    vs17-azureportal-new-settings
  8. On the the Create virtual machine – Summary blade, once the Validation passed message is displayed click OK to begin provisioning your new, awesome Visual Studio VM!!
    vs17-azureportal-new-summary
  9. It’ll take a few minutes to complete the provisioning of the VM. Go take a break, or post on Twitter how awesome Visual Studio + Azure is, then come back and get ready to “develop for the cloud, in the cloud”.

Congratulations! After following the previous steps, you will now have a Windows VM with Visual Studio pre-installed all ready for you to use to “develop for the cloud, in the cloud.”

Connect with Remote Desktop

Once you have a Visual Studio VM provisioned in Microsoft Azure, the next step is to connect to it with Microsoft Remote Desktop so you can start using it and writing code. Microsoft Remote Desktop provides an easy way to remotely connect to a Windows computer (physical or VM) and use it just as if you were sitting down at the machine. It includes full display, keyboard and mouse support along with MANY other useful features.

To connect to an Azure VM with Remote Desktop, you first need to get the IP Address of the VM to connect to, then you’ll be able to connect using a Remote Desktop Client and the Admin username and password that was configured for the VM at creation.

The Azure Portal actually goes a step further and provides you an easy to use .rdp file for download. This enables you to click a button in the Azure Portal, then download and open the .rdp file that contains the necessary connection information for VM. When opening this file in the Remote Desktop Client, the only thing you need to fill in is the Admin username and password to connect.

To help you locate the IP Address of the VM, as well as download the .rdp file, you can follow the below steps:

  1. Navigate to and login to the Azure Portal (http://portal.azure.com)
  2. Once logged into the Azure Portal, you’ll need to locate the Virtual Machine you want to connect to. To do this, you can navigate to your VM by first finding the Resource Group its in by clicking on Resource groups in the left hand navigation, then click on the specific Resource Group.
    vs17-azureportal-vm-resourcegroups
  3. On the Resource group blade, click on the Virtual Machine resource type in the list of resources within the Resource Group.
    vs17-azureportal-resourcegroup-vm
  4. On the Virtual machine blade for your VM, you will find the Public IP address of the VM within the Essentials pane. Also, clicking on the Connect button will download a .rdp file that can be opened within the Microsoft Remote Desktop client.
    vs17-azureportal-vm-connectip
  5. Once downloaded, you can open the .rdp file in the Microsoft Remote Desktop, then connect to your new Visual Studio VM running in Azure!
    • On Windows you can use the Microsoft Remote Desktop Connection client.
      msremotedesktopconnectionapp
    • On macOS the best option is to use the Microsoft Remote Desktop application that can be installed through the macOS App Store.
      macos-microsoftremotedesktop-appstore
  6. Once connected to the VM with Remote Desktop, if you provisioned the Visual Studio image from the Azure Marketplace that’s running Windows Server 2016, you’ll need to change the IE Enhanced Security Configuration setting. To do this, you’ll need to wait for the Server Manager window to pop up, then click on Local Server.
    winserver-servermanager-localserver
  7. Locate and click on the On text for IE Enhanced Security Configuration.
    winserver-servermanager-ieenhancedsecurityconfig-on
  8. In the Internet Explorer Enhanced Security Configuration window, select Off under Administrators, then click OK.
    winserver-servermanager-ieenhancedsecurityconfig-dialog
  9. Now you can open up Visual Studio 2017 in the VM and get coding!
    vs17-rc-vm-rdp-macos

Cost Saving Tips

If you’re not familiar with Azure billing and the difference resources involved when creating and hosting a Virtual Machine in Azure, then you may be a little worried about how much it’ll cost. So, I felt if was only natural to include some cost explanations and cost saving tips in this article. After you’ve provisioned a great Visual Studio development VM in Azure, it’s also important to keep the costs contained and as minimum as possible!

Below are some explanations on how Azure VM billing works along with a couple tips on how to save money and reduce hosting costs.

Azure VM Billing Explained

When provisioning an Azure Virtual Machine (VM) there are a number of resources provisioned that include things like the Public IP Address, Network interface, Networks security group, storage, and Virtual machine (the compute instance itself).

Here’s a screen capture of all the resources created for the previously provisioned Visual Studio VM. These resources are all created within the same Resource Group, in this case the Resource Group that was created for the VM as described in the previous steps.

vs17-vm-resourcegroup-resources

Here’s the same list of resources along with a short description of what they are used for:

  • Storage account – storage the VM’s disk image, other words the .vhd file
  • Virtual network – a software defined network (SDN) where the VM will reside
  • Virtual machine – the compute instance for the running VM; this is where the CPU/Memory are defined and reserved
  • Network interface – the software defined Network Interface Card (NIC) that connects the VM to the Virtual Network
  • Public IP address – the piece of the software defined networking stack that defines the Public IP address connectivity for the VM to have access to the Internet and to be connected to with Remote Desktop
  • Network security group – a configurable set of rules that essentially defines the Inbound and Outbound Firewall rules to secure the Virtual Network and VM

As you can see, the Azure VM is really more than just a virtual machine under the covers. Conceptually it’s just a single machine, but really it’s made up of a bunch of different Infrastructure as a Service (IaaS) parts that combine to make up the desired VM configuration. Each of these parts have their own pricing, and some don’t have any cost associated with them.

To start talking about Azure VM cost, let’s first start with the major pieces that will affect the majority of the cost of your VM. These are the Storage account and Virtual machine.

The Virtual machine resource in Azure is what defines the Compute resources (CPU Cores and Memory). This is was maps directly to the underlying hardware within the Microsoft Azure data center that actually runs the VM. This is what costs the most out of all the necessary resources for an Azure Virtual Machine. The cost of the Virtual machine resource will depend on the specific Instance Size (defining CPU Cores, Memory, and other features) you choose to run your VM, but will only be incurred when the VM is provisioned and running (we’ll cover what this means in further detail down further).

The Storage account resource in Azure is where the VM’s .vhd disk image file is stored. The VM may be running in the Virtual Machine resource, but the .vhd disk image is persisted in the Storage account resource.

Thirdly, not really a specific resource, but an important aspect that affects cost is the Bandwidth Egress. This is the transfer of outbound data from Azure out to other servers / endpoints across the Internet. The Ingress, or inbound bandwidth into Azure, is Free. Even though the Egress cost is rather low, it will affect the VM cost some, so it’s important to be aware of.

Lastly, the other resources that make up the VM will incur very little or no cost at all. The Public IP address may incur a very small cost, which depends on your configuration. The remaining resources (Network interface, Network security group, and Virtual network) alone don’t incur any cost and make up underlying Infrastructure that the VM requires to run on top of.

To assess and gain visibility into the cost of an Azure VM and actually all the resources within a Resource Group, you can access a Resource costs summary at the Resource Group level. To access this summary, you can follow these steps:

  1. Within the Azure Portal, navigate to the Resource Group blade for the desired Resource Group.
  2. In the list of links on the Resource Group blade, click on Resource costs.
    vs17-resourcegroup-resourcecosts-link
  3. On the Resource costs pane you will find a summary of the cost (or spend) of your resources in the Resource Group for the current billing period of your Azure Subscription.
    vs17-resourcegroup-resourcecosts-summary

As you can see from the screenshot, the majority of the cost of the shown VM is from the Virtual machine resource and some cost from the Storage account, with very little from the Public IP address, and nothing from the remaining resources.

vs17-subscription-chargesAnother place to view much further cost analysis and information on resources within your Azure Subscription is to view the Subscription Center within the Azure Portal. You can access this by clicking on the More services > link in the left-side Azure Portal navigation, then navigating to your Subscription.

 

How to Properly Shutdown a VM

There are 2 ways to shutdown an Azure VM, and they are certainly not equal! One way you will still get charged for the compute resources, and the other will free you from paying for the compute resources and help you reduce overall cost.

The first method to shutdown an Azure VM, that sounds logical in the context of connecting with Remote Desktop, is to Shutdown the Operating System. In this scenario you would be connected with Remote Desktop, and when done with your work you go to the Power options within Windows and select Shutdown. This will essentially “turn off” the VM and stop it from running. However, even though the VM won’t be running you WILL still be paying for the Virtual machine hardware allocation. Doing this will cause the Azure Portal to report the status of the VM to be “Stopped”.

vs17-azureportal-vm-stoppeddeallocated

The second method, and the one to remember, is to go into the Azure Portal (or use Azure PowerShell or Azure CLI) and Stop the VM. Instead of just shutting down the Operating System, Azure will also deallocate the hardware (CPU and Memory) allocation; thus releasing it to be used for another workload in Microsoft Azure. Doing this will cause the Azure Portal to report the status of the VM to be “Stopped (Deallocated)”.

While in the “Stopped (Deallocated” status, you will not be paying for the VM resources.

It’s a good idea that when ever you don’t actually need the VM to be running that you Stop it using the Azure Portal, PowerShell, or Azure CLI so that the resources are released. While in the “Stopped (Deallocated” status, you will not be paying for the VM resources. This will really help you save money!

To “properly” Stop a VM in the Azure Portal to release the resources and save money, you can follow these steps:

  1. Within the Azure Portal, navigate to the Virtual Machine blade for the desired VM.
  2. On the Overview pane, click the Stop button.
    vs17-azureportal-vm-stop-button

There is one caveat to be aware of when shutting down an Azure VM so it gets placed into the Stopped (Deallocated) status. Since this causes Azure to release the server resources associated with the Virtual Machine, it not only releases the CPU and Memory resources but also the Dynamic IP Address allocation. Due to this, when you Start the VM back up again, the IP Address will likely change. If you require the IP Address to never change for your VM, then you’ll need to configure a Static IP Address for the VM.

To start up a Stopped VM, you can follow these steps:

  1. Within the Azure Portal, navigate to the Virtual Machine blade for the desired VM.
  2. On the Overview pane, click the Start button.
    vs17-virtualmachine-start-button

Another point that’s important to remember when stopping Azure VM’s and placing them into the “Stopped (Deallocated)” state is that you do still pay for the Azure Storage account usage. Remember, the Storage account is where the VM’s .vhd disk image file is stored. Stopping the VM retains all the VM’s settings / configurations, as well as the .vhd image stored in Azure Storage. As a result, you will still incur some cost for the storage, but at least you will save on the VM resources. After all, the Storage will only cost a small amount of money compared to the much higher cost of the Virtual Machine resource allocation if it were left running constantly.

Schedule Auto Shutdown

Manually shutting down a VM to put it in the Stopped (Deallocated) status is a great way to save cost on Azure VM’s. Although, you do need to remember to Stop the VM. This introduces a certain level of human error in the process of saving you hosting costs on your Azure VMs. As a result, Microsoft has added a scheduled auto-shutdown feature into the platform to assist you in this effort.

With the Auto-shutdown feature, you are able to configure a specific Time (with Time Zone) when Azure is to automatically shutdown the VM. When configured, the VM will automatically be stopped if it is still running at that time of day.

To configure Auto-shutdown of an Azure VM, you can follow these steps:

  1. Within the Azure Portal, navigate to the Virtual Machine blade for the desired Virtual Machine.
  2. In the list of links on the Virtual Machine blade, click on Auto-shutdown.
    azureportal-vm-autoshutdown-link
  3. On the Auto-shutdown pane, configure the specific TimeTime Zone, and desired notification Webhook URL settings, then click Save.
    azureportal-vm-autoshutdown-pane

If you forget to Stop your VM at the end of the day, or whenever the Auto-shutdown time is configured it will get Shutdown automatically. When using a Visual Studio development VM, this can become a good thing on Friday afternoons (or any other day when you might be in a hurry) when you’re most likely to forget to shutdown the VM.

ContainersDevelopmentInfrastructure

Deploy Docker Containers to Azure Web Apps on Linux

The PaaS (Platform as a Service) offerings within Microsoft Azure have been getting expanded out pretty impressively lately. The “extreme PaaS” that is the serverless computing of Azure Functions is a really interesting direction for cloud computing. However, one of the of the latest changes is the ability to host Docker Containers on Linux within Azure App Service Web Apps! It seems Microsoft is starting to add Docker support to everything.

App Service Web Apps on Linux

A few weeks ago the initial preview release of Azure App Service Web Apps for Linux was released. This offers a way to host OSS applications (Node.js, Python, PHP, etc) in Azure App Service with the use of a Linux Virtual Machine (VM). This provides a great alternative to hosting all Azure Web Apps with a Windows Server VM and IIS. While IIS works, the option of using Linux is definitely more appealing to Linux and non-Microsoft developers looking to use the Microsoft Azure cloud.

To provision a new Azure App Service Web App on Linux, you can follow these steps:

  1. Within the Azure Portal, search the Marketplace for Web App on Linux.
    azportal_webapponlinux_marketplace
  2. Enter the App nameResource Group, and select an App Service Plan to create the Web App on Linux.
  3. Next a specific Container needs to be selected in order to configure the specific Language / Platform that will be used to deploy a Web App to the Web App on Linux App Service instance.
    azportal_webapponlinux_pickbuiltincontainer
  4. Once provisioned the new Web App on Linux will be deployed out to an Ubuntu Linux VM with the specified platform container deployed and ready to go.

As you can see from the above screenshot of the available Built-in containers to choose from there are a number of Language/Platform versions to choose from. The list of language/platform versions supported by the current Preview release of Azure Web Apps on Linux are:

  • .NET Core v1.0
  • Node.js 6.6.0
  • Node.js 6.2.2
  • Node.js 4.5.0
  • Node.js 4.4.7
  • PHP 5.6.23
  • PHP 7.0.8

There’s also another thing that can be seen within the above screenshot…

Azure Web Apps + Docker

webapplinux-dockercontainerThe platform features of Azure App Service Web Apps on Linux support the deployment and configuration of the hosting environment through the use of Docker Containers. This is a huge departure and powerful feature addition to Azure Web Apps on Linux that differs from how the original Azure Web Apps hosted with Windows Server and IIS is implemented.

The use of Docker Containers to configure and host Web Apps on Linux opens up a huge amount of possibilities that help push Azure Web Apps to a more powerful service than before. The Built-In Containers that can be chosen to host Node.js, PHP, or .NET Core applications are built out as Docker Containers.

With the support for Docker Containers bring along the ability to deploy any Docker container image from Docker Hub (http://hub.docker.com) as the basis for hosting an Azure Web App on Linux. Not just Node.js, PHP, or .NET Core images can be deployed. It actually supports the deployment of any Docker Container Image from Docker Hub. It also supports both Public and Private images in Docker Hub.

azportal_webapponlinux_dockerhubcontainer

In addition to supporting any Docker Container Image from Docker Hub, Web Apps on Linux also supports deploying container images from any Private registry as well. To deploy an image form a private registry, you simply provide a couple additional properties: Server URL, Login username, and Password.

azportal_webapponlinuxprivateregistrycontainer

The Docker Container Images used to deploy out the language / platform to host an app can be used to simply host a Web App as normally with Azure Web Apps. However, the Docker Container Image can also contain the entire application to host within Azure Web Apps on Linux; including the language / platform and the full custom application as well.

Deploy “Hello World” Container to Web App on Linux

As an example of a Docker Container Image that can be deployed to Azure App Service Web App on Linux that contains the language / platform as well as a sample, “hello world” style application, the following Docker Images can be used:

This is just a sample of a couple Docker images that can easily be used, and any Docker Image can be deployed out to an Azure Web App on Linux.

Here’s what the dimkk/ng2-admin Docker Image from Docker Hub looks like once it’s deployed out and hosted within a Web App on Linux instance:

webapponlinux_ng2-admin-running

To deploy out a Docker Image from the Docker Hub, you can use the following steps when provisioning a new Web App on Linux, or when modifying an existing Web App on Linux:

  1. For the Image source property, select Docker Hub.
  2. Specify Public or Private accordingly for the Repository Access field.
  3. Enter the Docker Image Name into the Image and optional tag field.

To use the ng2-admin image you can specify the Docker Image of dimkk/ng2-admin”.

webapponlinux_ng2-admin_container

In this example, once the Web App on Linux initializes the deployment of the Docker Container image “ng2-admin” or another that implements a full application, the app will be running.

There is also the Startup Command field when configuring a Docker Container Image for a Web App on Linux to specify a specific startup command to execute once the Docker Container is deployed.

Infrastructure

Hosting Azure Web App on Linux

Since the introduction of Azure App Service and Azure Web Apps in early 2015, as well as the Azure Websites feature even earlier, the only option has been to use a Windows VM underneath to host Web Apps. That was until recently! Microsoft recently released a new feature into Preview that allows Azure Web Apps to be hosted on a Linux VM under the covers. With the availability of the Azure Web App on Linux Preview it’s now possible to choose either Windows or Linux as the host OS for the underlying VM Web Apps are deployed to.

With the availability of the Azure Web App on Linux Preview it’s now possible to choose either Windows or Linux as the host OS for the underlying VM Web Apps are deployed to.

Provisioning an Azure Web App on Linux

Once logged into the Azure Portal (http://portal.azure.com), the “Web App on Linux” option is available within the Azure Marketplace when choosing what resource(s) to provision in an Azure Subscription.

Clicking on “+NEW” in the portal will reveal Web App on Linux under the “Web + mobile” section of the Marketplace, or by typing in “Web App on Linux” in the marketplace search.

azureportal_new_webapponlinux

azureportal_webapponlinux_provisioningOnce the Web App on Linux resource is chosen, the prompt to choose the settings for creating a new “Web App on Linux” deployment is almost identical to the options when creating a standard “Web App” deployment that uses the Windows OS. The App name, Resource Group, and App Service Plan are still required just the same, as well as the option to turn App Insights On or Off.

However, there is an additional option to specify. The additional option is the Runtime Stack. The Runtime Stack configuration is a required field that specifies the specific version of either Node.js or PHP that is necessary for the chosen deployment.

The available options (at least in the current Preview state of the service) for Node.js version are:

  • Node.js 6.6.0
  • Node.js 6.2.2
  • Node.js 4.5.0
  • Node.js 4.4.7

The available options (at least in the current Preview state of the service) for PHP version are:

  • PHP 7.0.8
  • PHP 5.6.23

It’s worth noting that even though the PHP or Node.js version needs to be specified when creating a new Web App on Linux resource, the version can be changed later on within the Application settings for the Web App. It is also possible to switch the configuration from Node.js to PHP or the other way on an existing Web App on Linux resource as well.

Supported Regions

Since the Web App on Linux service is currently in Preview, it’s not supported to be deployed out to all Azure regions just yet. This is part of the standard way with how Azure Preview services are rolled out and eventually deployed across the Microsoft Azure Platform. First, Preview services are rolled out to only 1 or a few Azure regions / locations. Then, later on, once the service reached General Availability (GA) the service will be rolled out to be supported across the rest of the Microsoft Azure regions / locations.

It the current Preview state of the Web App on Linux support, the service is available in the following 3 regions:

  • West Europe
  • Southeast Asia
  • West US

Pricing Plans

While it’s expected that Web Apps on LInux will eventually receive the same App Service plan Pricing tier support once the service reached General Availability (GA), the current Preview doesn’t support all the same pricing tiers just yet. Currently, it supports a few of the Pricing tiers for the smaller Instance Sizes which still give plenty of options to use this new Preview service.

Here’s the list of the currently supported Pricing tiers for the Web App on Linux Preview service:

  • Standard S1 (1 Core, 1.75 GB RAM)
  • Standard S2 (2 Cores, 3.5 GB RAM)
  • Standard S3 (4 Cores, 7 GB RAM)
  • Basic B1 (1 Core, 1.75 GB RAM)
  • Basic B2 (2 Cores, 3.5 GB RAM)
  • Basic B3 (4 Cores, 7 GB RAM)

webapponlinux_preview_pricingtiers

As can be seen in the above screenshot of the Pricing tier options, there are many standard features of Azure Web Apps supported.

  • Up to 50 GB Storage
  • Custom domains
  • SSL Support
  • Up to 10 instances
  • Daily backup
  • Up to 5 Deployment Slots

Each of the Azure App Service Pricing tiers for the Web App on Linux Preview service also shows a listing of “Preview Pricing” for both the Standard and Basic pricing tiers. This indicates that the pricing of the Web App on Linux service while it’s in Preview is actually charged at a 50% discount of the prices shown. The price displayed for the Standard S2 tier is $89.29 USD, so with the 50% discount, the price you’ll pay to use a Standard S2 instance with the Web App on Linux Preview will actually be $44.65 USD.

Linux App Service Plan

When provisioning a Azure Web App, whether a “standard” Web App or a Web App on Linux, there needs to be an Azure App Service Plan provisioned. The App Service Plan is what determines the Pricing tier and each App Service Plan can be used to host 1 or more Web Apps. There is however a difference between the App Service Plans.

An App Service Plan for a Web App for Linux resource can only be used to host other Linux based Web Apps, and an App Service Plan for a “standard” Web App resource can only be used to host Windows based Web Apps.

While a Web App or a Web App on Linux can be provisioned, the starting point you use (which of these that’s chosen to start provisioning) will determine the NEW App Service Plan that gets created. A Web App, as it’s hosted on a Windows VM underneath, will have a Windows based App Service Plan provisioned. A Web App on Linux, as it’s hosted on a Linux VM underneath, will have a Linux based App Service Place provisioned.

However, there’s one thing to be aware of when provisioning a new Web App if there are already both Windows based and Linux based App Service Plans running on an Azure Subscription. When a new Web App is created, although it will create NEW App Service Plans that support Windows, if an existing Linxed based App Service Plan is chosen as the App Service Plan to use for hosting the Web App, the resulting Web App that gets provisioned, since it’s configured to use a Linux App Service Plan, will in fact be a Web App on Linux instead. This is a seemingly small detail that needs to be kept in mind when provisioning both Web App and Web App on Linux resources within an Azure Subscription.

What distribution of Linux?

Since Azure Web Apps are a Platform as a Service (PaaS) service in the cloud, it does fully abstract away the underlying Virtual Machine (VM) and Operating System (OS) that is hosting the Web App. However, there are times when it’s useful to know what OS and Version is hosting something, and using the Kudu portal (which is available to all Azure Web Apps) it’s possible to gleam into what OS, Web Server, and other System Information of the underlying OS.

The OS that Web App on Linux resources / instances are running on is: Debian GNU/Linux 8 (jessie)

webapponlinux_prev_releaseinfo

Also, the web server running on the Web App on Linux resource / instances is: Apache/2.4.10

Here is some additional Environment / System information about the Linux VM underneath Web App on Linux instances.

System info

  • System up time: 3.17:07:04.9990000
  • OS version: Unix 4.4.0.38
  • 64 bit system: True
  • 64 bit process: True
  • Processor count: 1
  • Machine name: fc53b9b63c6f
  • Instance id: fc53b9b63c6f
  • Short instance id: fc53b9
  • CLR version: 4.0.30319.42000
  • System directory:
  • Current working directory: /
  • IIS command line: /usr/lib/mono/4.5/mod-mono-server4.exe –filename /tmp/mod_mono_server_default –applications /:/opt/Kudu –nonstop

Environment variables

  • APACHE_LOCK_DIR = /var/lock/apache2
  • APACHE_LOG_DIR = /var/log/apache2
  • APACHE_PID_FILE = /var/run/apache2/apache2.pid
  • APACHE_RUN_DIR = /var/run/apache2
  • APACHE_RUN_GROUP = www-data
  • APACHE_RUN_USER = www-data
  • APPDATA = /opt/Kudu/local
  • APPSETTING_SCM_USE_LIBGIT2SHARP_REPOSITORY = 0
  • APPSETTING_ScmType = None
  • APPSETTING_WEBSITE_AUTH_ENABLED = False
  • APPSETTING_WEBSITE_NODE_DEFAULT_VERSION = 4.4.7
  • APPSETTING_WEBSITE_SITE_NAME = linuxwebapp42
  • DEBIAN_FRONTEND = noninteractive
  • DOTNET_SKIP_FIRST_TIME_EXPERIENCE = true
  • HOME = /home
  • HOSTNAME = fc53b9b63c6f
  • HTTP_HOST = linuxwebapp42.scm.azurewebsites.net
  • KUDU_APPPATH = /opt/Kudu
  • KUDU_MSBUILD = /usr/bin/xbuild
  • KUDU_RUN_USER = 31c21a883af01a04cb9bd231
  • LANG = C
  • MONO_IOMAP = all
  • MONO_SHARED_DIR = /tmp
  • NUGET_XMLDOC_MODE = skip
  • PATH = /home/site/deployments/tools;/opt/Kudu/bin/Scripts;/usr/bin;/usr/bin;;;Microsoft SDKs/F#/3.1/Framework/v4.0;/usr/bin;/usr/share/npm;/usr/local/bin;/usr/local/bin;/usr/local/bin;/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/nodejs/4.5.0/bin
  • PWD = /
  • SCM_BIN_PATH = /opt/Kudu/bin
  • ScmType = None
  • SITE_BITNESS = AMD64
  • WEBSITE_AUTH_ENABLED = False
  • WEBSITE_NODE_DEFAULT_VERSION = 4.5.0
  • WEBSITE_SITE_NAME = linuxwebapp42

It’s worth nothing that anywhere the value “linuxwebapp42” is shown in the above settings / information that this is the Name of the Web App on Linux that was created and subsequently used to access all this information.

If you’re curious how the above Environment / System information was obtained, it was retrieved by using the Kudu portal. Kudu is the engine used behind the scenes for git/hg deployments, WebJobs, and various other features of Azure Web Apps. Every instance of Azure Web Apps (both Windows and Linux) have an instance of Kudu running that can be accessed through the Azure Portal or directly via its HTTP endpoint.

Open SourcePowerShell

PowerShell now Open Source AND Cross-Platform! Linux, macOS, Windows

Windows PowerShell the new Shell (first released in 2006) for Windows that provides the ability to implement Task Automation, and Configuration Management via a Command-Line Shell and PowerShell scripting language built on the .NET Framework. PowerShell is an extremely strong tool and has become a staple in managing various Windows systems from the OS to SharePoint to the cloud and Microsoft Azure. Today, Microsoft has officially released PowerShell cross-platform support via an Open Source project that supports Linux, macOS and Windows! Read More