Managing IIS Using Microsoft IIS Administration Rest API On Azure VM

Introduction

In this article, I will teach you about getting started with managing IIS, using Microsoft IIS Administration REST API on Azure Virtual Machines in very simple steps.

Pre-requisite

  • Microsoft Azure Account
  • Azure Virtual Machine
  • IIS 7.5 and above being enabled
  • .NET Core 

Tip -  Ensure enabling IIS before installing .NET Core in order to receive ASP.NET Core Module.

Overview

The genesis of developing REST API for managing IIS was Nano Server. If you have new name Nano Server, then in simple terms, it's Windows Server 2016, a slimmed -down version of Windows Server. Inet-manager, religiously being used to manage IIS for some reason doesn’t work for Nano Server. This made IIS team need to work on a way to open up IIS configuration system.

Architecture Overview

Microsoft Administration API for IIS is developed as an ASP.NET Core Application, which allows you to leverage the merits of the Web API conventions that MVC framework offers. In order to allow the user to configure IIS round the clock whenever required, it was necessary to run the Application as a Service.

IIS team took advantage of Hostable Web Core, a technology which allows the consumer to have an in-process version of IIS to enable required API behavior. Once HWC gets loaded, the process has access to all the capabilities IIS offers. As HWC uses its own applicationHost.config file, any configuration changes made to IIS does not affect the action of the Service, using HWC.

HTTPS

Micro Service

To express in simpler terms, Microsoft IIS Administration is a self-hosted Windows Service, which exposes all the functionality of underlying IIS over to RESTful API.

Microsoft IIS Administration API recently had its first preview release. The preview can be experienced by visiting https://manage.iis.net

Let’s Get Started,

Open https://manage.iis.net on your Azure Virtual Machine, an Application with the screen, mentioned below will be displayed.

Now, this Application is designed & developed to manage your IIS machines running Microsoft administration API. This Application is accessible from anywhere through the Web Browser. Hence, if it’s mobile, tablet, or desktop, you can manage your machines right from anywhere across the globe. Doesn’t it sounds fantastic!

Application is in preview and IIS team has to ensure they add more cool features with further releases.

Welcome screen being displayed allows you to download Microsoft IIS Administration API, very much needed by the Application in order to run.

Click Download Microsoft IIS Administration and follow the installer to get API installed.HTTPS
Note

If you already have API installed, you can skip the download and directly move to the connection screen.

Once you've clicked on download, the screen will appear with the message, shown below, along with in-progress gif icon.

Open => IIS AdminsitrationSertup.exe file is being downloaded.

HTTPS

HTTPS

Follow the instruction. Click => Run.

HTTPS

Check ‘I Agree’ checkbox, once you read the terms and the condition thoroughly.

Click => Install.



This installation will take a few minutes, depending upon certain IIS features  being enabled in your machine. If IIS Windows Authentication and IIS Hostable Web Core are not enabled, the installer will enable them.

The Window, shown below will be displayed after successful installation.

HTTPS

You can check the Service running at Services Window (open using services.msc command), as highlighted below.

HTTPS

After successful installation, the Application will prompt you to  enter your machine credentials and it will keep prompting whenever it will try to talk with Machine IIS.

Currently, only administrator group members & IIS administrators group have access to manage IIS, using administration API.

HTTPS

Now, after validating the credentials, connection screen, shown below will be displayed.

Connection screen is filled with some default names for the local machine.

As seen, you need to generate Access Token in order to get connected &talk with API.

Click => Get Access Token. 
HTTPS
Click = > Create Access Key. 

HTTPS
Enter the required information, along with selecting the validity of token from the options, mentioned below.

Here, I have selected only one day as its validity.

Click => Create it.

HTTPS

Token will be generated, as shown below.

HTTPS

You can also refresh or delete the Token with the provided option as highlighted in the image, mentioned below.

As you can see, it will display a few details of Token being generated along with the time remaining for it to be expired.

HTTPS
Coming back to Connection page, enter the Token generated in Access Token field.

You can check an option for having a token stored locally. Go for this option only if you’re accessing it through the private device.

Once all the data is entered, click Connect.
HTTPS
Now, you are connected with your machine IIS, as shown below.

All the Websites configured in your machine will be displayed here.

You can perform all the activities related to IIS configuration, like stopping the Application, starting the Application, changing app pool, restarting app-pool and many other from this UI.

Let’s create a Website in Azure Virtual Machine through this Application.

Click Create WebSite, as highlighted in the image, shown below.

HTTPS
Enter the required details, as shown below

Name - Name of the Website.
Physical path - Its physical file location.
Application Pool, Bindings if any.

HTTPS

You can also select from existing Application pool or can create one.

For this article, I have entered the details, mentioned below. 

HTTPS

Also, select DefaultPool as Application pool for the newly created Website.

Once done with configuring, click Create.



Now, let’s open our Inet Manager in Azure Virtual Machine to check our newly created Website. As seen, it’s created, but not yet started.

HTTPS

Coming back to manage the Application, the newly created Website is now listed.

Notice, the status here is stopped, as seen in Inet manager Window.

Click highlighted icon for the Website, as shown in the image, shown below to start the Website.

HTTPS

Again, verify it in Azure Virtual Machine Inet Manager Window.

Cool! The Website now starts.

HTTPS

Similarly, you can experience all IIS features like
,

  • Changing & creating Applications pool
  • Authentication.
  • Authorization.
  • Default document.
  • Directory Browsing options.
  • Response header.
  • IP restriction, if any.
  • Logging configuration.

Through this you can manage the application, through Microsoft IIS Administration API.

HTTPS
Microsoft IIS Administration API also provides an in built API Explorer, which allows the developers to utilize the deep-in features exposed by administration API.

At the top right, you will find the link to browse API Explorer.

It will redirect you to connect to the window, shown below, where it requires the same token, which you generated.

Alternatively, you can create a new token also.

Enter Token and check the box for keeping you connected and click Connect.

HTTPS

You will be navigated to the window, shown below, where you can deep dive with all the methods and results exposed by Administration API.

We will learn more about this in later articles.

HTTPS

Conclusion

We saw how Microsoft IIS administration API made life easy by allowing us to manage our Azure Virtual IIS machine on Hand-go reach.

This API is useful in scenarios where you have a Hybrid deployment Model with different Nano Servers, Windows Servers etc to manage and deploy from one single UI.

Also, this supercool API plays a very useful role for Continuous Integration and Continues Development model.

Official Documentation is not yet released. I hope you will have found this article useful and productive. I would recommend you to try it once.

Happy Azure coding!

References

https://blogs.iis.net/adminapi


Similar Articles