Microsoft IIS Administration Rest API on Azure VMs
Microsoft IIS Administration Rest API on Azure VMs
In this article, learn how to get started with managing IIS using Microsoft IIS Administration REST API on Azure Virtual Machines.
Join the DZone community and get the full member experience.Join For Free
SnapLogic is the leading self-service enterprise-grade integration platform. Download the 2018 GartnerMagic Quadrant for Enterprise iPaaS or play around on the platform, risk free, for 30 days.
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.
- Microsoft Azure Account
- Azure Virtual Machine (we will be using Azure VM for this article)
- IIS 7.5 and above being enabled
- .NET Core
Note: Ensure enabling IIS before installing .NET Core in order to receive ASP.NET Core Module.
The genesis of developing REST API for managing IIS was Nano Server. If you have a newly named 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 the IIS team need to work on a way to open up the IIS configuration system.
Microsoft Administration API for IIS was 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 that 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.
To express in simpler terms, Microsoft IIS Administration is a self-hosted Windows Service that 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 this site.
Let’s Get Started!
Open this site on your Azure Virtual Machine. An application with the screen mentioned below will be displayed.
Now, this application is designed and developed to manage your IIS machines running Microsoft administration API. This application is accessible from anywhere through the Web Browser. If it’s mobile, tablet, or desktop, you can manage your machines right from anywhere across the globe. Doesn’t that sound fantastic!
The application is in preview and the IIS team has to ensure that they add more cool features with further releases.
The welcome screen being displayed allows you to download Microsoft IIS Administration API, which is very much-needed by the Application in order to run.
Click Download Microsoft IIS Administration and follow the installer to get API installed
Note: If you already have the API installed, then you can skip the download and directly move to the connection screen.
Once you've clicked Download, the screen will appear with the message, shown below, along with an in-progress GIF icon.
Open the IIS AdminsitrationSertup.exe file to download it.
Follow the instruction. Click Run.
Check the I Agree checkbox once you read the terms and the condition thoroughly.
This installation will take a few minutes depending upon certain IIS features being enabled on your machine. If IIS Windows Authentication and IIS Hostable Web Core are not enabled, then the installer will enable them.
The window shown below will be displayed after successful installation.
You can check the service running in the services window (open using the services.msc command), as highlighted below.
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 and IIS administrator groups have access to manage IIS using the administration API.
After validating the credentials on the connection screen the screen shown below will be displayed. The connection screen is filled with some default names for the local machine. As seen, you need to generate the access token in order to get connected and talk with the API.
Click Get Access Token.
Click Create Access Key.
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.
The token will be generated, as shown below.
You can also refresh or delete the token with the provided option as highlighted in the image below. As you can see, it will display a few details of the token being generated along with the time remaining for it to be expired.
Coming back to the Connection page, enter the Token generated in the 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.
Now, you are connected with your machine IIS, as shown below. All of 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 Web Site, as highlighted in the image below.
Enter the required details as shown below:
Name: name of the website.
Physical path: its physical file location.
Application pool: bindings, if any.
You can also select from existing application pool or can create one. For this article, I have entered the details shown below.
Also, select DefaultPool as the 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.
Coming back to manage the application, the newly created website is now listed. Notice that the status here is stopped, as seen in Inet manager window. Click the highlighted icon for the website, as shown in the image, shown below to start the website.
Again, verify it in the Azure Virtual Machine Inet Manager Window.
Cool! The website now starts.
Similarly, you can experience all IIS features like:
- Changing and creating applications pool
- Default document
- Directory browsing options
- Response header
- IP restriction, if any
- Logging configuration
You can manage the application through the Microsoft IIS Administration API.
The Microsoft IIS Administration API also provides an built-in 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. Enter Token, check the box for keeping you connected, and click Connect.
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.
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 super cool API plays a very useful role for Continuous Integration and Continuos Development models.
The official documentation is not yet released. I hope you found this article useful and productive.
Happy Azure coding!
Opinions expressed by DZone contributors are their own.