Skip to main content
DevOps Image

This post is from the XebiaLabs blog and has not been updated since the original publish date.

Last Updated Jul 24, 2014 — DevOps Expert

Deploying the same .NET site to IIS and Azure PaaS using XL Deploy

DevOps

Last week, I was invited by Microsoft partner Cellenza to talk about XL Deploy during their BootCamp tech rally. Of course, we could have shown them our IIS+SQL Server deployment demo, but I wanted to take this opportunity to dig into a new subject: Microsoft Azure. Specifically, I was wondering how easy it would be to deploy the same web application package either to an on-premise IIS instance or to Azure's Web Apps (i.e. PaaS layer).

Connecting to Azure

The first thing was too find out how to communicate with Azure. The answer I found turned out to be Azure's Cross-Platform Command-Line Interface, a set of CLI commands based on node.js. npm install azure-cli -g gives you commands to drive Azure. Before you can run any commands, you also need to import your Windows Azure Publish Settings file in the tool:
vagrant@azure:~$ azure account import /vagrant/data/my.credentials.publishsettings
 info: Executing command account import
 info: account import command OK
Once done, you can create your website using this command:
vagrant@azure:~$ azure site create --location "West Europe" xld-benoit-demo
 info: Executing command site create
 + Getting sites
 + Getting locations
 info: Creating a new web site at xld-benoit-demo.azurewebsites.net
 \info: Created website at xld-benoit-demo.azurewebsites.net
 +info: site create command OK
To deploy your website, you need to put the content into an SCM (GitHub, in my case). Azure hooks into the SCM and triggers a deployment each time there is a commit. The following command links the website to a GitHub account and repository:
vagrant@azure:/vagrant/data$ azure site create --location "West Europe" xld-benoit-demo2 --github --githubusername bmoussaud --githubpassword ******* --githubrepository bmoussaud/azure-ws
 info: Executing command site create
 + Getting sites
 info: Updating existing site
 + Getting locations
 + Retrieving repositories
 + Getting site information
 + Retrieving website hooks
 + Creating new hook
 + Testing hook
 info: site create command OK
Of course, you need to transfer your SSH key onto the machine on which the Azure xplat-cli is installed.

Integration with XL Deploy

The azure.Gateway CI is a generic container on which the Azure xplat-cli is installed. It contains a single property credentialsPublishSettings that contains the files with the key, and two control tasks to import the credential file and list the accounts:
<type type="azure.Gateway" extends="generic.Container">
  <property name="credentialsPublishSettings" size="large"/>
  <!-- control tasks -->
  <method name="importsettings"/>
  <property name="importsettingsScript" default="azure/import-settings" hidden="true" />
  <method name="accounts"/>
  <property name="accountsScript" default="azure/accounts" hidden="true" />
</type>
--- azure/import-settings.sh ---
echo "Importing credential settings"
echo '${container.credentialsPublishSettings}'  > ./credentials.publishsettings
cat ./credentials.publishsettings
azure account import ./credentials.publishsettings
--- end azure/import-settings.sh ---
azure-gateway-definitionThe azure.Website CI is a Deployed targeted at the azure.Gateway container. It manages the website creation and deletion:
<type type="azure.Website" extends="generic.ExecutedScript"
  container-type="azure.Gateway" deployable-type="iis.WebsiteSpec">
  <property name="location" default="West Europe"/>
  <property name="fqdn" />
  <property name="githubUsername" category="GitHub" />
  <property name="githubPassword" password="true" category="GitHub"/>
  <property name="githubRepository" category="GitHub" />
  <property name="destroyScript" default="azure/delete-website" hidden="true" />
  <property name="createScript" default="azure/create-website" hidden="true" />
</type>
--- azure/create-website.sh ---
echo "Creating webserver ${deployed.name}/${deployed.fqdn}"
azure site create --location "${deployed.location}" ${deployed.fqdn} --github --githubusername ${deployed.githubUsername} --githubpassword ${deployed.githubPassword} --githubrepository ${deployed.githubRepository}
--- end azure/create-website.sh ---
--- azure/delete-website.sh ---
echo "Removing webserver ${deployed.id}"
echo "azure site delete -q ${deployed.fqdn}"
azure site delete -q ${deployed.fqdn}
--- end azure/delete-website.sh ---
The azure.PublishedWebContent CI is another Deployed targeted at the azure.Gateway container. It manages the web content:
--- azure/deploy-website.sh ---
echo "Deploying website content ${deployed.name} on ${deployed.container.name} Microsoft Azure Website"
git clone git@github.com:${deployed.githubRepository}.git workingdir
cp -r ${deployed.file}/* ./workingdir
cd workingdir
git add -A
git commit -a -m "Commit for Deployment of ${deployed.deployedApplication.version.application.name}/${deployed.deployedApplication.version.name}"
git push
--- end azure/deploy-website.sh ---
The script clones the GitHub repository, copies the content, commits and pushes. In the definitions of the two deployed CIs, the two deployable types are those defined in the IIS plugin. Based on this extension, it is now possible to use XL Deploy to deploy a deployment package containing a .NET website either to a standard IIS web server running on a Windows server (running on-premise or, indeed, in Azure's IaaS!) or to an Azure Web Site.
[caption id="attachment_7432" align="alignnone" width="300"]website-on-iis Deploying to a standard IIS server (Click to Expand)[/caption][caption id="attachment_7433" align="alignnone" width="300"]website-on-azure Deploying the package to Microsoft Azure (Click to Expand)[/caption]

More from the Blog

View more
Sep 13, 2021

The Expedited Journey of Digital Transformation

DevOps
Alan Brown, Digital Transformation Advisor at Digital.ai conducts a se ...
Read More
Aug 23, 2021

Is Data Analytics Missing From Your Digital Transformation?

DevOps
Nearly every major enterprise is already in the process of digital tra ...
Read More
Aug 19, 2021

Creative Ways to Automate Developer Workflows

DevOps
When an organization begins an Agile or DevOps journey, the process ca ...
Read More
Aug 12, 2021

How Automation Enhances Efficiency and Delivery Speed In a DevOps Environment

DevOps
When organizations make the decision to move to a DevOps environment, ...
Read More
Contact Us