Nano Server: Deploying ASP.NET 5 site on Internet Information Services (IIS) Web Server


Since the previous blog post about Nano Server: Building an Internet Information Services (IIS) Web Server, I have been experimenting with deploying ASP.NET 5 on Nano Server and have posted an article on TechNet Wiki on how to prepare a Nano Server with IIS Web Server role to host ASP.NET 5 sites. While we are waiting for Windows Server 2016 to reach RTM phase, I believe the Microsoft Internet Information Services (IIS) team will be making a lot more improvements till the launch date and I am anticipating the deployment will get a lot easier.

You can either view this article from the Microsoft TechNet Wiki which may have any improvement updates by the TechNet community on the link below;

Or carry on reading this page on the original article which I have noted in my engineering journal with some explanations on the process.

The Original TechNet Wiki Article on Nano Server: Deploying ASP.NET 5 site on Internet Information Services (IIS) Web Server

 

1. Introduction

In this article, we will demonstrate deploying ASP.NET 5 capabilities to Internet Information Services (IIS) on a Windows Server 2016 Technical Preview 4 Nano Server and allowing Nano Server to host ASP.NET 5 application.

 

2. ASP.NET 5 with Web Server (IIS) on Nano Server Requirements

You will need the followings to host ASP.NET 5 application on Nano Server;

 

3. Getting Started with ASP.NET 5 with Web Server (IIS) on Nano Server

In order to publish an ASP.NET 5 application, we will require the Nano Server to have Internet Information Services (IIS) capability and you can refer to the following article below;

 

3.1. Deploying a new Nano Server with ReverseForwarder and Web Server (IIS) packages

For those who want to start a fresh Nano Server, the PowerShell example in creating a Nano Server with the basic package requirements below:

# Import New-NanoServerImage PowerShell Module for Technical Preview 4
Import-Module `
    -Global C:\NanoServer\NanoServerImageGenerator.psm1 ; 

 

# Create New Basic NanoServer Image with IIS for Technical Preview 4 with IIS and ReverseForwarders Package
New-NanoServerImage `
    -MediaPath "Z:" `
    -BasePath "C:\NanoServer\Base" `
    -TargetPath "C:\NanoServer\WS16TP4NSIIS1\WS16TP4NSIIS1.vhd" `
    -EnableRemoteManagementPort `
    -Language "en-us" `
    -GuestDrivers `
    -DriversPath "C:\NanoServer\VMware-Drivers" `
    -Packages "Microsoft-NanoServer-IIS-Package, Microsoft-OneCore-ReverseForwarders-Package" `
    -Ipv4Address "192.168.100.25" `
    -Ipv4SubnetMask "255.255.255.0" `
    -Ipv4Gateway "192.168.100.3" `
    -DomainBlobPath "C:\NanoServer\WS16TP4NSIIS1.djoin" `
    -AdministratorPassword (ConvertTo-SecureString -String "Password" -AsPlainText -Force) ; 

 
 

3.2. Deploying ReverseForwarders package for Web Server (IIS) on existing Nano Server

If you already have an existing Nano Server with Internet Information Services (IIS) package but are missing the ReverseForwarders package, you can follow the example starting from here below:

# Establish a remote PowerShell Session to the Nano Server
Enter-PSSession `
    -ComputerName 192.168.100.24 `
    -Credential (New-Object `
        -TypeName System.Management.Automation.PSCredential `
        -ArgumentList "192.168.100.24\Administrator", `
        (ConvertTo-SecureString `
            -String "Password" `
            -AsPlainText `
            -Force) `
    ) ; 

 
 

3.2.1. Create the Packages folder to contain the ReverseForwarder Packages

Firstly, we will need to create the Packages folder structure to contain the CAB files.

# Create a Packages folder in Nano Server
New-Item `
    -Path "C:\Packages" `
    -Type directory ; 

 

# Create an en-us language folder for Packages folder in Nano Server
New-Item `
    -Path "C:\Packages\en-us" `
    -Type directory ; 

Now, we need to exit the current PSSession from your remote Nano Server so that we can copy the CAB files from your mounted Windows Server 2016 Technical Preview 4 ISO image on the management server.

# Exit PowerShell Session
Exit-PSSession ; 

Verify you have the PowerShell version 5 on your management server so that you will have the new capability for Copy-Item to copy files using UNC path to the remote Nano Server.

# Show PowerShell version for Copy-Item
$PSVersionTable ;

 

3.2.2. Copy the Packages from Management Server to Nano Server remotely

With PowerShell version 5, you will be able to using Copy-Item cmdlet to copy the files from your management server to the remote Nano Server using UNC path. You will need to ensure that your remote Nano Server firewall is enabled to allow File and Printer Sharing.

# Copy ReverseForwarders Package from DVD to Nano Server remotely
Copy-Item `
    -Path "D:\NanoServer\Packages\Microsoft-OneCore-ReverseForwarders-Package.cab" `
    -Destination "\\192.168.100.24\C$\Packages" ;  

 

# Copy ReverseForwarders Package from DVD to Nano Server remotely
Copy-Item `
    -Path "D:\NanoServer\Packages\en-us\Microsoft-OneCore-ReverseForwarders-Package.cab" `
    -Destination "\\192.168.100.24\C$\Packages\en-us" ; 

 
Windows Nano Server - IIS - ASP - Build Process 1 - Copy ReverseForwarder

 

3.2.3. Add ReverseForwarder packages to Nano Server

Once we have copied the 2 ReverseForwarders CAB files, you will need to connect to the Nano Server remotely using Enter-PSSession and use DISM to add the package to your existing Nano Server.

# Add ReverseForwarder package to Nano Server
dism /online /add-package /packagepath:C:\Packages\Microsoft-OneCore-ReverseForwarders-Package.cab 

Windows Nano Server - IIS - ASP - Build Process 2 - Adding ReverseForwarder

Next, you will require to add the en-us language version of ReverseForwarders package.

# Add en-us language ReverseForwarder package to Nano Server
dism /online /add-package /packagepath:C:\Packages\en-us\Microsoft-OneCore-ReverseForwarders-Package.cab 

 

# Restart the Nano Server remotely
Restart-Computer -Force ; 

 
Windows Nano Server - IIS - ASP - Build Process 3 - Adding usa ReverseForwarder
 
 

3.3. Deploying httpPlatformHandler v1.2 x64 to Nano Server

After we have IIS and ReverseForwarders package deployed on the Nano Server, we will require to deploy httpPlatformHandler for ASP.NET 5 application.
 

3.3.1. Download httpPlatformHandler v1.2 x64 from a Management Server

Let’s download the httpPlatformHandler MSI to the Management Server so that we can extract the files.

# Create a Temp folder
New-Item `
    -Path "C:\Temp" `
    -Type directory ; 

 

# Download HttpPlatformHandler v1.2 x64 to C:\Temp 
Invoke-WebRequest `
    -Uri "http://go.microsoft.com/fwlink/?LinkId=690721" `
    -OutFile "C:\Temp\httpPlatformHandler_amd64.msi" ; 

 

# Verify HttpPlatformHandler v1.2 x64 has been downloaded
Get-ChildItem `
    -Path "C:\Temp\httpPlatformHandler_amd64.msi" ; 

 
Windows Nano Server - IIS - ASP - Build Process 4 - Download httpPlatformHandler

 

3.3.2. Extract httpPlatformHandler content on Management Server

After the download, we will extract the httpPlatformHandler MSI to a temporary location and copy the content to the Nano Server remotely.

# Extract httpPlatformHandler v1.2 x64 MSI Files
Start-Process `
    -FilePath msiexec.exe `
    -ArgumentList "/a C:\Temp\httpPlatformHandler_amd64.msi /qb TARGETDIR=C:\Temp\httpPlatformHandler_v1.2_amd64" `
    -Wait `
    -PassThru ; 

 

3.3.2. Copy httpPlatformHandler content to Nano Server remotely

Now, you will copy those httpPlatformHandler files to the appropriate location on Nano Server.

# Copy the HttpPlatformHandler.dll file 
#  from extracted folder to Nano Server remotely
Copy-Item `
    -Path "C:\Temp\httpPlatformHandler_v1.2_amd64\inetsrv\HttpPlatformHandler.dll" `
    -Destination "\\192.168.100.24\C$\Windows\System32\inetsrv" ; 

 

# Copy the httpplatform_schema.xml file 
#  from extracted folder to Nano Server remotely
Copy-Item `
    -Path "C:\Temp\httpPlatformHandler_v1.2_amd64\inetsrv\config\schema\httpplatform_schema.xml" `
    -Destination "\\192.168.100.24\C$\Windows\System32\inetsrv\config\schema" ; 

 
Windows Nano Server - IIS - ASP - Build Process 5 - Extract httpPlatformHandler
 

3.3.4. Configure Internet Information Services (IIS) to allow httpPlatformHandler

After we have copied those httpPlatformHandler files to Nano Server, we need to configure the IIS use the httpPlatformHandler.

# Import IIS Administration PowerShell Module
Import-Module IISAdministration ; 

 

# Add AppSettings section (for Asp.Net Core)
(Get-IISServerManager).GetApplicationHostConfiguration().RootSectionGroup.Sections.Add("appSettings") ; 

 

# Unlock handlers section
(((Get-IISServerManager).GetApplicationHostConfiguration()).GetSection("system.webServer/handlers")).OverrideMode = "Allow" ; 

 

# Add httpPlatform section to system.webServer
((Get-IISServerManager).GetApplicationHostConfiguration().RootSectionGroup.SectionGroups["system.webServer"].Sections.Add("httpPlatform")).OverrideModeDefault = "Allow" ; 

 

# Add httpPlatformHandler.dll to globalModules
New-IISConfigCollectionElement `
    -ConfigCollection (Get-IISConfigSection "system.webServer/globalModules"  | Get-IISConfigCollection) `
    -ConfigAttribute @{"name"="httpPlatformHandler";"image"="%SystemRoot%\system32\inetsrv\httpPlatformHandler.dll"} ; 

 

# Add httpPlatformHandler module to modules
New-IISConfigCollectionElement `
    -ConfigCollection (Get-IISConfigSection "system.webServer/modules"  | Get-IISConfigCollection) `
    -ConfigAttribute @{"name"="httpPlatformHandler"} ; 

 

# Commit Changes on IIS Server Manager
(Get-IISServerManager).CommitChanges() ; 

Windows Nano Server - IIS - ASP - Build Process 6 - Install httpPlatformHandler

 
 

3.4. Create an ASP.NET 5 site on Nano Server

Finally, we will have to create the ASP.NET 5 site on the Internet Information Services (IIS) in the Nano Server.

# Create a folder
New-Item `
    -Path "C:\ASP-Site" `
    -Type directory ; 

 

# Create a folder
New-Item `
    -Path "C:\ASP-Site\wwwroot" `
    -Type directory ; 

 

# Create a new IIS Website for ASP.NET 5
New-IISSite `
    -Name "ASP-on-NanoServer" `
    -BindingInformation "*:5004:asp.nanoserver.naboo.co.nz" `
    -PhysicalPath "C:\ASP-Site\wwwroot" ; 

 

# Allow HTTP 5004 through Windows Firewall
New-NetFirewallRule `
    -Name "AspNetCore" `
    -DisplayName "HTTP on TCP/5004" `
    -Protocol tcp `
    -LocalPort 5004 `
    -Action Allow `
    -Enabled True ; 

 

# Verify the new IIS Site is created
(Get-IISServerManager).Sites 

 
Windows Nano Server - IIS - ASP - Build Process 7 - Add ASP Site
 
 

4. Conclusion

That is all for preparing the Internet Information Services (IIS) with ASP.NET 5 capabilities. The remaining work will require you to copy your published ASP.NET project across to the IIS site path which is more related to ASP.NET article such as installing .NET Version Manager (DNVM), working with .NET Execution Environment (DNX) and .NET Development Utilities (DNU) to compile and publish the output to be copied across to the IIS site path.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s