Automate the creation of your Webapp with VI and Azure Cloud Shell.

Automate the creation of your Webapp with VI and Azure Cloud Shell.

During Build, Microsoft announced the long awaited public preview of Azure Cloud Shell. Azure Cloud Shell improves productivity by enabling automatic and secure access to a preconfigured workstation built for Azure, on Azure. As part of today, you can login into your management portal and hit on this logo.

You need to create an Azure File Share as Cloud Shell machines are temporary. The Azure file share needs to be mounted to persist your $Home directory. On your first launch Azure Shell prompts you to create a resource group, storage account and file share. Accept them, create them and hit VI – a screen-oriented text editor originally created for the UNIX operating system. PowerShell support will come soon.

As an example – let’s create a webapp in Azure trough VI. But, ultimately before getting into VI; hit AZ to see all commands available for you. Here are all the commands that you could use for your Azure Cloud Shell. To complete our example; we need to use webapp cmdlet who is designed to manage our webapps.

Basically when you hit az (be careful as its case sensitive) webapp create, the Cloud Shell will show you the parameters that it requires before creating the webapp. For you information as well, not only the create argument is available, but all those arguments could be used within the webapp command: show, list, delete, config, list-runtimes, start, restart, stop, browse, deployment, log, create.

What you need as a minimum for creating any webapp is as per following:

  • A Resource Group
  • A unique Name
  • An existing Service Plan

When you have all of them; hit the following and quite VI by :w filename

az webapp create –resource-group RG_STORAGE –name SharePointRocks –plan serviceappplantest

For running any “script” under Bash, you need to make your script executable by changing the permissions or by simply writing bash in front of your VI script name (-again be carefull; it’s case sensitive – don’t write BASH all in capitals or createwebapp as it won’t recognize the command)

Hit bash create WEBAPP

After a few seconds the Azure Cloud Shell will create your webapp and show you all the parameters of your site. Navigate to your resource group and you’ll see that the webapp is created.

That’s it, simple but powerful. A lot of scenarios can be written like:

  • Stop my webapp(s)
  • Restart my webapp(s)
  • Mass creation of webapps for testing purpose
  • …. and all within a few lines of VI.

As shown you before in the article, with the AZ command you can do a lot, and make your life easier with the combination of VI

Have fun!

Gokan Ozcifci

I own a company and work a lot with #SharePoint. Entrepreneur. Microsoft Regional Director and @MVPAward for Office Servers and Services.

Leave a comment

Your email address will not be published. Required fields are marked *

Recent Posts
Sponsor