Microsoft Hybrid Cloud blogsite about Management

Tag Archives: Bash

Azure Cloud Shell is an interactive, browser-accessible shell for managing Azure resources. It provides the flexibility of choosing the shell experience that best suits the way you work. Linux users can opt for a Bash experience, while Windows users can opt for PowerShell.

In this quick overview you will see the possibilities of Microsoft Azure Cloudshell functionalities and tools.

Azure Cloudshell Editor

Azure Cloud Shell includes an integrated file editor built from the open-source Monaco Editor. The Cloud Shell editor supports features such as language highlighting, the command palette, and a file explorer.
This can be handy with JSON and YAML files.

When you have your App YAML file for your Azure Kubernetes Cluster on your Cloud drive, you can edit the file online with your browser and save it in the Azure Cloud. I like this editor in the Cloudshell, especially when you are not behind your own laptop or pc and you have to make a quick change.

I have a Kubernetes Cluster installed on Azure and with this editor I can explore my Azure logs, Cache, and config files for the information I need to work with in Bash, Powershell to do my CLI commands for example 😉

Kubectl is a command line interface for running commands against Kubernetes clusters. kubectl looks for a file named config in the $HOME/.kube directory. You can specify other kubeconfig files by setting the KUBECONFIG environment variable or by setting the –kubeconfig flag.Read here more about Kubectl

Terraform CLI is Available

What is Terraform?
Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions.
Configuration files describe to Terraform the components needed to run a single application or your entire datacenter. Terraform generates an execution plan describing what it will do to reach the desired state, and then executes it to build the described infrastructure. As the configuration changes, Terraform is able to determine what changed and create incremental execution plans which can be applied.
The infrastructure Terraform can manage includes low-level components such as compute instances, storage, and networking, as well as high-level components such as DNS entries, SaaS features, etc.

The key features of Terraform are:

Infrastructure as Code
Infrastructure is described using a high-level configuration syntax. This allows a blueprint of your datacenter to be versioned and treated as you would any other code. Additionally, infrastructure can be shared and re-used.

Execution Plans
Terraform has a “planning” step where it generates an execution plan. The execution plan shows what Terraform will do when you call apply. This lets you avoid any surprises when Terraform manipulates infrastructure.

Resource Graph
Terraform builds a graph of all your resources, and parallelizes the creation and modification of any non-dependent resources. Because of this, Terraform builds infrastructure as efficiently as possible, and operators get insight into dependencies in their infrastructure.

Change Automation
Complex changesets can be applied to your infrastructure with minimal human interaction. With the previously mentioned execution plan and resource graph, you know exactly what Terraform will change and in what order, avoiding many possible human errors.

AzCopyis a command-line utility designed for copying data to/from Microsoft Azure Blob, File, and Table storage, using simple commands designed for optimal performance. You can copy data between a file system and a storage account, or between storage accounts.

Conclusion :

Microsoft Azure Cloudshell is very powerful to work with, creating your infrastructure from the Command Line Interface (CLI) or with JSON / YAML scripts. Some features or commands are not available in the Azure portal and that’s where Azure Cloudshell can help you out. Try the different Azure Cloudshell Tools and look what you like most to use for your work. From here you can work on any device with a browser and do your work. #MVPBuzz

Azure Cloud Shell is an interactive, browser-accessible shell for managing Azure resources. It provides the flexibility of choosing the shell experience that best suits the way you work. Linux users can opt for a Bash experience, while Windows users can opt for PowerShell

When you installed VSC you can add Extensions to your Visual Studio Code and one of them is Called Azure Account.
When you Add this extension you can connect to Microsoft Azure Cloud Shell in Visual Studio Code.
But before we can use this Extension to connect to Azure CloudShell we need NodeJS version 6 or higher installed on your OS.

Azure Cloud Shell is an interactive, browser-accessible shell for managing Azure resources. It gives you the flexibility of choosing the shell experience that best suits the way you work. Linux users can opt for a Bash experience, while Windows users can opt for PowerShell.

At the left corner you can change from Powershell Cmd to Bash

Bash with Azure CLI 2.0

FeaturesBrowser-based shell experience
Cloud Shell enables access to a browser-based command-line experience built with Azure management tasks in mind. Leverage Cloud Shell to work untethered from a local machine in a way only the cloud can provide.

Choice of preferred shell experience
Azure Cloud Shell gives you the flexibility of choosing the shell experience that best suits the way you work. Linux users can opt for a Bash experience, while Windows users can opt for PowerShell.

Pre-configured Azure workstation
Cloud Shell comes pre-installed with popular command-line tools and language support so you can work faster.

Connect your Azure File storage
Cloud Shell machines are temporary and as a result require an Azure Files share to be mounted as clouddrive to persist your $Home directory. On first launch Cloud Shell prompts to create a resource group, storage account, and file share on your behalf. This is a one-time step and will be automatically attached for all sessions. A single file share can be mapped and will be used by both Bash and PowerShell in Cloud Shell.

In the following step-by-step examples ( in Bash and Powershell ) you will see how easy it is to make an Azure Container Instance in the Cloud.
we begin with starting Bash Shell from the Azure Portal.

When you run Cloud Shell for the first time it will create a Cloud Drive of 5GB.

Cloud Shell machines are temporary and as a result require an Azure Files share to be mounted as clouddrive to persist your $Home directory. On first launch Cloud Shell prompts to create a resource group, storage account, and file share on your behalf. This is a one-time step and will be automatically attached for all sessions. A single file share can be mapped and will be used by both Bash and PowerShell in Cloud Shell.

Create Storage for your CloudDrive

A locally-redundant storage (LRS) account and Azure Files share can be created on your behalf. The Azure Files share will be used for both Bash and PowerShell environments if you choose to use both. Regular storage costs apply.

Cloud Shell runs on a temporary machine provided on a per-session, per-user basis

Cloud Shell times out after 20 minutes without interactive activity

Cloud Shell can only be accessed with a file share attached

Cloud Shell uses a the same file share for both Bash and PowerShell

Cloud Shell is assigned one machine per user account

Permissions are set as a regular Linux user (Bash)

az container create -h

With this command you see the options to create a Container Instance in Microsoft Azure Cloud.

You see also some examples to learn from

az group create –name MyResourceGroup –location eastus

We now created a resource group in the East US location of Azure for our Container.

To see how your Azure Container Instance is doing, you can read the logs.

az container logs –name mycontainer –resource-group MyResourceGroup

When your Azure Container Instance was for testing, you can delete the instance by :

az container delete –name mycontainer –resource-group MyResourceGroup

az container list –output table

I got two Azure Container Instances running, and now you can see that mycontainer instance is deleted.
This was just an simple example by using Bash in the Azure Portal with CLI 2.0 commands. Of course there are a lot of Azure Solutions to play with:

In the following step-by-step example we will use Azure Powershell from the portal instead of Bash :