Automating Deployment with Microsoft Web Deploy
Scott Guthrie lives in Seattle and builds a few products for Microsoft
Automating Deployment with
Microsoft Web Deploy
This is the twenty-eighth in a
series of blog posts
I’m doing on
the VS 2010 and .NET 4 release.
This blog post continues a series of posts I’m doing that cover the new
improvements we made around web deployment. In my
first post
in the deployment series I
provided an overview of the new
VS 2010 Web Deployment
features.
In today’s post I’m going to be discussing Microsoft Web Deploy – which is
a free server technology that enables a comprehensive publishing and deployment
mechanism. Web Deploy enables you to not only publish files – but also
provision database schema/data, run database change scripts, set security ACLs,
and more. All of these deployment steps can be automated using Visual Studio.
This post will provide a step by step tutorial on how to install Web Deploy
and enable it on a web-server. I’ll then demonstrate how you can use
Visual Studio 2010 to directly publish to servers using Web Deploy, as well as
how you can use Visual Studio to create installation packages that you can use
to automate the deployment of your applications.
Web Deploy – And Why Should You
Care
Deploying a web application or site involves several steps. You typically
need to:
- Copy files and folders
- Provision database schema and optionally populate database content
- Set appropriate read/write and security ACLs on files and folders
- Install and configure SSL certificates
-
Deploy other misc dependencies (Event logs, GAC libraries, COM
objects, etc)
Performing all of these steps manually is tiresome, slow, and dangerous
(since manual deployment steps are error prone). Enabling an automated
process that allows you to quickly provision and deploy applications on a
server helps reduce the chances of things going wrong, and can dramatically
improve the cycle time it takes for you to get a change you make in an
application into production.
Microsoft Web Deploy
Web Deploy is a free technology built by my team that can improve web
deployment. It is a deployment service that runs on a server, and enables you
to either locally or remotely deploy applications onto it. Web Deploy
includes built-in support for creating virtual directories and applications
within IIS, copying files and folders, provisioning databases (both SQL Server
and MySQL), setting file-system ACLs and more (it even includes built-in
providers for things like setting registry entries, registering COM components,
etc). In addition to having these built-in deployment features, it also
supports a .NET based provider API that enables you to create and plug-in your
own custom deployment actions – which allow you to customize it however you
want.
The wire-protocol for Web Deploy is HTTPS – which means Web Deploy can be
used through firewalls (enabling easy, secure, deployment to remote hosted
servers). Web Deploy also supports both admin and non-admin deployment
scenarios. The non-admin scenarios enable administrators to configure Web
Deploy on a server, and then delegate a subset of deployment capabilities to
developers who do not have admin accounts on the production
server. This enables a very secure and flexible deployment
approach. I’ll cover the configuration steps to enable delegated
deployment scenarios in my next blog post in this series.
Installing Web Deploy on Windows
Server 2008
Visual Studio 2010 (and Visual Web Developer 2010 Express) will by default
install Web Deploy on your development machine as part of their setup.
This
3) Press the Install Button. This will download and install the Web
Deployment Package, and enable the IIS Management Service feature that is
built-into Windows.
Enabling Deployments with Windows
Server 2008
We now have Web Deploy installed – next we need to enable deployments with
it.
Web Deploy supports deployments by administrators, as well as deployments
by non-administrators (aka delegated deployments). In this blog post,
I’m going to cover how to enable deployments using an account that has
administrator permissions on the server. I will cover how to enable
delegated deployments by developers that do not have an administrator account
in my next blog post in this series.
1) The first step to enable Web Deploy is to start the IIS Admin Tool
(Start -> Run -> inetmgr.exe). Then double-click the “Management
Service Delegation” icon on the home-
3) Press the Install Button. This will download and install the Web
Deployment Package, and enable the IIS Management Service feature that is
built-into Windows.
Enabling Deployments with Windows
Server 2008
We now have Web Deploy installed – next we need to enable deployments with
it.
Web Deploy supports deployments by administrators, as well as deployments
by non-administrators (aka delegated deployments). In this blog post,
I’m going to cover how to enable deployments using an account that has
administrator permissions on the server. I will cover how to enable
delegated deployments by developers that do not have an administrator account
in my next blog post in this series.
1) The first step to enable Web Deploy is to start the IIS Admin Tool
(Start -> Run -> inetmgr.exe). Then double-click the “Management
Service Delegation” icon on the home-screen:
screen:
provides you with what you need to create Web Deployment setup packages
within VS, as well as publish them to remote servers that have the Web Deploy
service installed and enabled.
Below are the steps for how to install Web Deploy on a production server
running IIS 7.x on Windows Server 2008 or Windows Server 2008 R2:
1) Download and run the
Microsoft
Web Platform Installer
on your production server.
2) Click the “Web Platform” tab within the Web Platform Installer, then
click the “Customize” link under the “Web Server” section. Select the
“Web Deployment Tool 1.1” feature as well as the “Management Service” feature:
bring you to a page that looks like below. In the Actions pane, click the
“Edit Feature Settings…” link. This will bring up the “Edit Feature
Settings” dialog - check the “Allow administrators to bypass rules” option
within this dialog box. This will allow those with Administrator accounts
on the server to bypass the delegation capabilities of the Web Management Service
and perform actions using their
administrator capabilities:
“Managem
ent Service” icon:
When you double-click the “Management Service” icon it will bring you to a
page that looks like below. Click the “Enable Remote Connections”
checkbox to enable remote deployments. You can optionally choose which IP
address and port the management service runs on – as well as what client IP
addresses are allowed to connect with it. You can tweak these settings to
lock down who can access the deployment service.
When you are done click the “Start” link within the “Actions” tab to start
the Web Management Service on the server:
The server is now setup for deployments using an administrator account with
Web Deploy.
Important Tip: One thing to watch for is whether you have a
firewall enabled on your server, or within the cluster where your server is
hosted. By default the Management Service runs using the HTTPS protocol
on port 8172. This port might be locked down by default depending on your
hosting configuration. If so you should either unlock it with your
firewall/hoster – or pick a different port number that is allowed. You
can test to see whether the management service is available simply by opening
up a browser and accessing it using a URL like: https://yourservername:8172/MsDeploy.axd – if you are
prompted for a username/password then you know it is working, and there is no
firewall blocking access to it. If it times out then it is likely that a
firewall is blocking it.
Enabling Web Deploy on a
non-Windows Server 2008 Operating System
The steps above demonstrate how to enable the Web Deploy service on a
Windows Server 2008 or Windows Server 2008 R2 operating system. The IIS 7
Management Service is built-into these operating systems, and Web Deploy takes
advantage of it.
If you try and follow the above steps on Windows 7, Windows Vista, or
Windows Server 2003, though, you’ll notice that the IIS Management Service (and
its icon within the IIS admin tool) isn’t available. Instead you need to
follow a slightly different set of steps to enable the Web Deploy service.