Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Deploying to azure web sites
1. Deploying to Azure Web Sites
Introduction
ThisdocumentdescribeshowtosetupanEPiServerCMSsite to run onAzure WebSites.Formore
informationsee Azure WebSites.Here anemptysite iscreatedfromVisual Studiointegrationbut
the most stepsdescribedappliestoothersitesaswell.
Create site
In Visual Studioselectcreate newProjectandchose EPiServerWebsite (eitherMVCor WebForms).
Note that thisrequiresEPiServerVisual Studioadd-ontobe installed.
Project references
Install NuGetpackagesEPiServer.Azure andEPiServer.CMS.Core tothe project(the referencesforthe
projectwill automaticallybe updatedtouse the NuGetpackagesinsteadof GACinstalledassemblies
whichisrequiredforpublishingthe site).
Create Azure resources
Create Azure Web Site
Openthe Azure managementportal andselectoption“WEBSITES” inthe leftmenu.Select“NEW”in
the bottomleftcornerand inthe dialogselect“CUSTOMCREATE”. Give an URL foryour website and
selectaRegionof your choice.Selectalsotocreate a new SQL database.Indatabase settingseither
selectanexistingseverorcreate a newone and give a login userandpassword.
Create Azure Storage
WhenrunningonAzure the media(forexample images) shouldbe storedinAzure blobstorage to
enable elasticscaling.Tocreate a blobstorage account go to the Azure Managementportal and
select“STORAGE”from the leftmenu.Select“NEW”in the bottomleftcornerandin the dialogselect
“QUICK CREATE”. Give an URL forthe storage andselecttocreate the storage account.
Tip: Create twoblobstorage accounts, one fordevelopmentandone forproduction,tomake iteasy
to switchbetweenthemusingjustthe connectionstring.
Create Service Bus
To be able toscale the site to run on several instanceswe needtosetupa Service Busto handle
messagesbetweenthe site instances.Tocreate a service busgo to Azure Managementportal and
select“SERVICEBUS” fromthe leftmenu.Select“CREATE”inthe bottommenuandin the dialog
selectanamespace name anda region.
Tip: Create twoservice busaccounts,one for developmentandone forproduction,tomake iteasy
to switchbetweenthemusingjustthe connectionstring.
Install database schema
OpenDeploymentCenterandchoose option“InstallSQLServerdatabase”.Inthe dialogthatopens
enterthe name of the SQL serverinAzure,the database userandpassword.The settingscanbe
foundinAzure Managementportal underthe createdAzure WebSite tothe right under“View
connectionstrings”.Indropdownselectthe database thatwascreatedduringcreationof Azure Web
Site.
2. Update configuration
EPiServer.Framework.config
OpenupEPiServer.Framework.configandaddthe followingblocktomapblobandeventprovidersto
Azure:
<blob defaultProvider="azureblobs">
<providers>
<add name="azureblobs"
type="EPiServer.Azure.Blobs.AzureBlobProvider,EPiServer.Azure"
connectionStringName="EPiServerAzureBlobs" container="MySiteMedia"/>
</providers>
</blob>
<event defaultProvider="azureevents">
<providers>
<add name="azureevents"
type="EPiServer.Azure.Events.AzureEventProvider,EPiServer.Azure"
connectionStringName="EPiServerAzureEvents" topic="MySiteEvents"/>
</providers>
</event>
Attribute containerforblobproviderand topicforeventprovidershouldbe unique persite within
the same storage or service busaccount.
connectionStrings.config
In connectionStrings.configchange connectionstringEPiServerDBtothe connectionstringfrom
Azure Managementportal (see Install databaseschema).Rememberthoughtokeepsetting
MultipleActiveResultSets=true.
Adda connectionstringnamed“EPiServerAzureBlobs”(aname thatmatchesthe settingin
EPiServer.Framework.configforthe provider).The connectionstringtothe blobstorage shouldbe in
format:
connectionString="DefaultEndpointsProtocol=https;AccountName=<name>;AccountKey=<key>"
where <name>iswhat wasgiveninsection“Create Azure Storage”.<key>can be foundinAzure
Managementportal under“Storage”if youselectthe name and thenselect“MANAGEACCESSKEYS”
inthe bottommenu.
Adda connectionstringnamed “EPiServerAzureEvents”(aname thatmatchesthe settingin
EPiServer.Framework.configforthe provider).The connectionstringtoService Buscanbe foundin
Azure Managementportal under“SERVICEBUS” if you selectthe name thatwas giveninsection
“Create Service Bus”and select“ACCESSKEY”in the bottommenu.
Tip: Connectionstringscanbe definedonanAzure WebSite underthe tab “CONFIGURE”whichis a
convenientwaytohave differentconnectionstringsforstagingandproduction.
episerver.config
In episerver.configchange the settingsiteUrl onelementepiserver/sites/site/siteSettingstothe site
that wascreatedundersection“Create Azure WebSite”.The URL can be foundinAzure
Managementportal under“WEB SITES” if you selectthe createdwebsite andselectdashboardin
the top menu.Thenthe site URL is giveninrightcolumn.
Web.config
The database schemafor Workflow3.5 (thatis the versionEPiServerCMScurrentlyuse) isnot
supportedinAzure database.Therefore the configurationforWorkflow persistence service mustbe
3. removed(thatisthe entrywithtype SqlWorkflowPersistanceService under
workflowServices/runtime).
The ASP.NETbuilt-inschemaformembership,role andprofile providersare notsupportedonSQL
Azure,therefore the configurationforthose SQLprovidersshouldbe changedtouse ASP.NET
Universal Providers(those are addedautomaticallytothe projectwheninstallingthe EPiServer.Azure
package).Change the providerstothe followingnew typesinweb.config:
System.Web.Providers.DefaultRoleProvider, System.Web.Providers
System.Web.Providers.DefaultMembershipProvider, System.Web.Providers
System.Web.Providers.DefaultProfileProvider, System.Web.Providers
Create an admin/edit user
Before deployingtoAzure create auserthat have access to adminandeditmode.Youdo thisby
configuringMultiplexingRoleProviderandMultiplexingMembershipProviderasdefaultprovidersto
enable Windowsauthenticationlocallyonyourmachine.Thenbrowse the site locallybutwiththe
database connectionstringsetupagainstthe database inAzure.Thengotoadminmode and under
“AdministerGroups”create twogroups WebAdminsandWebEditors.Thencreate auserthat is
memberof boththe createdgroups.Configure the site withSQLmembership/roleprovidersas
defaultprovidersandensure thatthe createdusercan loginandaccess adminmode.
Deployment using FTP
In Azure Managementportal youcan downloadapublishprofile forthe website byselectingthe site
and dashboardfromtop menu.Thenyoufind“Downloadthe publishprofile”inthe rightmenu.You
can use thisprofile lateronto publishyourtemplatesdirectlyforwithinVisualStudio.
If you openthe settingsfile youcanfindFTPaccesssettingsthere.OpenupaFTP client(forexample
FileZilla) andconnecttoyourAzure WebSite usingthe settings.
Navigate intowwwrootfolderonthe ftphostand sendoverfilesfromyourlocal site root(itis
enoughtosendfilesnecessarytorunsite like forexample bin,modulesbinetc.if youare uncertain
youcan sendall files).
Thennavigate one level uponftphost(foldercalledsite) anduploadappdatafoldertothat location.
Tip: Increase the numberof maximumparalleluploadsinFileZillatothe maximumof 10 to increase
uploadperformance whenyouuploadalarge amountof filessuchasappdata.
Deploying Content
The recommendedwaytotransferdatato an EPiServersite runningonAzure WebSitesistouse
EPiServerCMSExport/Importfunctionality.There are howeverotheroptionslike the migration
wizardto migrate an existingSQLServerdatabase.
Deployment through source control
It ispossible toconfigure Azure WebSitessoitusesacontinuousdeploymentfromsource code
control.It supportsforexample Git,GitHubandTFS. Fora full descriptionsee PublishfromSource
control.
Basicallyitworksinthe way that whenyoudoa committo yoursource control WindowsAzure will
getthe latestcode fromthe source control builditand deploy the outputtothe website(when
workingwithalocal git repositoryyoucaninsteadpushyourchangesto Azure WebSites).
4. Azure will buildyourprojectandpublishthe filesreferencedbythe projectinthe same wayas a
publishfromvisual studioworks.ForanEPiServerCMSsite there are some additional resourceslike
folderappdata (containsforexampleprotectedadd-ons) andfoldersmodules/modulesbin(that
containpublicadd-ons) thatare neededtobe able torun the site.
Here there are some optionsonhowto handle this additional resources.The synchronizationof files
whenAzure deploysfilestothe Azure WebSite worksso that it keepstrackof filesthatare inthe
code repositoryandonlythose filesare changedduringdeployment.Thatmeansthatmanually
transferredfileswillnotbe modified/deletedduringcontinuousdeployment.
No modules in source control
One optionisto not include those additionalfoldersinthe source code repositoryandinsteaduse
FTP to transferthe files. Additional add-onscanthenbe installeddirectlyonthe site runningon
Azure.
Modules included in source control
The other optionistohave the resourcesincludedinthe source code repository.Thenadd-onscould
be handledinthe waythat theyare firstinstalledonalocal site.Thenwhenverifiedthatthe add-on
workas expectedthe resource folderis committedandthendeployedtothe site runninginAzure.
Since the deploymenttothe website inazure onlyincludesfilesreferencedbythe projecta
modificationtothe deploymentneedstobe done sothe additional resourcesare includedinthe
deployment.
Duringthe deploymentprocesstoAzure website the “deployer”willlookforafile named
.deployment,if itexistitwill use itfordeploymentotherwise itwillcreate adefault.deploymentfile.
To be able tohandle additional resourcesthe .deploymentfile(oractuallythe dependent
deploy.cmd) needstobe modified.The firststeptodois to generate the fileslocally,how todothat
isdescribed here.The files.deploymentanddeploy.cmdshouldbe addedtosource control inthe
root (fora normal CMS projectthe source code repositoryrootshouldbe the foldercontaining
wwwrootandappdata).
Afterthat the deploy.cmdneedstobe modifiedsoitincludessynchronizationof appdata,modules
and modulesbinfolders. Asanexampleof amodifieddeploy.cmdfirstsome variablesare addedin
the setuppart afterthe onesalreadyinthe file,like:
SET NEXT_APPDATA_MANIFEST_PATH=%NEXT_MANIFEST_PATH%appdata
SET PREVIOUS_APPDATA_MANIFEST_PATH=%PREVIOUS_MANIFEST_PATH%appdata
SET NEXT_MODULESBIN_MANIFEST_PATH=%NEXT_MANIFEST_PATH%modulesbin
SET PREVIOUS_MODULESBIN_MANIFEST_PATH=%PREVIOUS_MANIFEST_PATH%modulesbin
SET NEXT_MODULES_MANIFEST_PATH=%NEXT_MANIFEST_PATH%modules
SET PREVIOUS_MODULES_MANIFEST_PATH=%PREVIOUS_MANIFEST_PATH%modules
setcurrent=%DEPLOYMENT_TARGET%
pushd..
setDEPLOYMENT_ROOT=%cd%
popd
5. Andin the deploymentpartsome additionaldeploymentcallsare addedlike:
call %KUDU_SYNC_CMD% -v 50 -f "%DEPLOYMENT_SOURCE%<wwwroot>modulesbin"-t
"%DEPLOYMENT_TARGET%modulesbin"-n"%NEXT_MODULESBIN_MANIFEST_PATH%" -p
"%PREVIOUS_MODULESBIN_MANIFEST_PATH%"
call %KUDU_SYNC_CMD% -v 50 -f "%DEPLOYMENT_SOURCE%<wwwroot>modules"-t
"%DEPLOYMENT_TARGET%modules"-n"%NEXT_MODULES_MANIFEST_PATH%" -p
"%PREVIOUS_MODULES_MANIFEST_PATH%"
call %KUDU_SYNC_CMD% -v 50 -f "%DEPLOYMENT_SOURCE%appdata"-t
"%DEPLOYMENT_ROOT%appdata"-n"%NEXT_APPDATA_MANIFEST_PATH%" -p
"%PREVIOUS_APPDATA_MANIFEST_PATH%"
Note that itusesa tool kuduSyncinsteadof forexample xcopy.kuduSyncwilluse manifestfilesto
keeptrack of whichfilesthatare presentina deployment.Thenatnextdeploymentitwill compare
the current state withthe previousmanifestfile andcanthendetermine whichfilesthathave been
added/deletedetc.