For full deployments, you can deploy the PartsUnlimited app to slots as needed. The website is setup to keep the connection strings with the slots. This means that if staging and main website slots are switched, the main website will still use the production database, while the staging slot will keep pointing to the staging database.
Note: If you follow the Continuous Deployment with VSTS Release Management HOL, it will automatically deploy this solution for you using VSTS.
- Open PartsUnlimited.sln at the root of the directory
- If you haven’t already done so, install PowerShell Tools for Visual Studio by following these steps:
- Right-click on the
PartsUnlimitedEnv
folder (the deployment project root) and choose Deploy -> New Deployment… - Choose subscription to deploy to.
- Under Resource Group choose New…
- Enter Resource Group name
- Name should not include periods.
- Choose Resource group location.
- Enter Resource Group name
- For Deployment template, choose
fullenvironmentsetupmerged.json
. - For Deployment template parameters, choose
fullenvironmentsetupmerged.param.json
. - Click Deploy.
- If prompted, edit the parameter to add any required value for the deployment template.
- Do not fill in values for anything that has ‘auto-generated’ for its value.
PartsUnlimitedHostingPlanSKU
needs to be value that supports slots or else the deployment will fail. (I took out the Free hosting plan from available hosting plans for the full setup template, but still worth noting for- The SQL Server name (specified by
PartsUnlimitedServerName
) should be all lowercase - The Storage Account names (specified by
CdnStorageAccountName
,CdnStorageAccountNameForDev
andCdnStorageAccountNameForStaging
) should be all lowercase and be 3 to 24 characters in length - The Storage Container names (specified by
CdnStorageContainerName
,CdnStorageContainerNameForDev
andCdnStorageContainerNameForStaging
) should be all lowercase and be 3 to 63 characters in length
- If prompted fill in any values the scripts ask for. This will only happen if you leave a non-auto-generated parameter blank.
- Now that the environment is setup, it is time to publish the website bits.
- Open PartsUnlimited.sln.
- Wait for package loads to complete.
- Build the project
- Right-click on
src\PartsUnlimited
project and choose Publish… - For Publish Web Wizard
- On Profile Page
- Choose ‘Microsoft Azure Web Apps’ under ‘Select a publish target’. Select the website created above. (Website name specified by
WebsiteName
parameter name in picture above.) This time choose the ‘WebsiteName(slotname)’ website to publish to a slot for the website. - Click Next.
- Choose ‘Microsoft Azure Web Apps’ under ‘Select a publish target’. Select the website created above. (Website name specified by
- On Connection Page, just click Next. This should be automatically filled out when the website was chosen on the previous page.
- On Settings Page, verify the configuration is what you want (i.e. Release – Any CPU).
- On Preview Page. Click Publish
- Users can click ‘Start Preview’ to verify the deployment will work, if they wish.
- On Profile Page
- Wait for publish to complete and load the website.
- The website is set up to automatically update the database shape, only if the database is empty. No extra EF migrations commands needed for the first deployment.
- Website is all setup to use slot switching. Users can publish to individual slots as they need. Website is setup to keep the connection strings with the slots. This means that if staging and main website slots are switched the main website still uses the production database.