Recently I encountered a customer asking if it’s possible to download a site using msdeploy.exe. This is pretty easy using msdeploy.exe. I’ll demonstrate this with Microsoft Azure Web Sites but you can use this with any hosting provider that supports Web Deploy (aka MSDeploy).
To perform a sync with msdeploy.exe the structure of the command that we need to execute is as follows.
msdeploy.exe –verb:sync –source:–dest:
For the source property we will use the remote Azure Web Site, and for the dest property we will write to a folder on the local file system. You can get the Web Deploy publishing settings in the Azure Web Site by clicking on the Download the publish profile link in the Configure page.
This will download an XML file that has all the publish settings you’ll need. For example below is a publish settings file for my demo site.
The publish settings file provided by Azure Web Sites has two profiles; an MSDeploy profile and an FTP profile. We can ignore the FTP profile and just use the MSDeploy one. The relevant settings from the profile that we will use are the following values.
- publishUrl
- msdeploySite
- userName
- usePWD
We will use the contentPath MSDeploy provider to download the files. On the source parameter we will need to include the relevant details of the remote machine. The full command to execute is below. I’ll break it down a bit after the snippet.
"C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:contentPath=sayeddemo2, ComputerName="https://waws-prod-bay-001.publish.azurewebsites.windows.net/msdeploy.axd?site=sayeddemo2", UserName=$sayeddemo2,Password=***removed***,AuthType='Basic' -dest:contentPath=c:\temp\pubfromazure -disablerule:BackupRule
More