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
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.
click install .
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.
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
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 c onnect .
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.