Now that we have our Sitecore environment on Azure PaaS, lets get some code on there!
I’m going to use Visual Studio to deploy my code, in the same way we can publish code locally to the website if we’re not working in the web root of the project. Of course, you can have your deployment process fully automated using things like FTP, PowerShell and more.
In the Azure portal, I can select the server I’d like to deploy to and select the ‘…More’ option to be able to download the PublishSettings file.
Little side note, if you wanted to upload your code through FTP you can get the username and password to use from the PublishSettings file as well – just open the file in your favourite text editor.
All details required for the FTP connection are there. Also, if you were silly enough to put your username and password on the Internet, you can reset your publish settings by going going back to the Azure portal and in the server blade select the ‘Reset publish profile’ options.
Back to deploying our code through Visual Studio: We now can open (or create) our solution in Visual Studio and select ‘<New Custom Profile>’ in the Publish dropdown. Just give the profile a name, go back to the Profile button and select the ‘Import’ option. Here, you can select the PublishSettings file we downloaded earlier.
At this point you’ll get an overview of the connection Visual Studio created for you, which we can then validate.
Now all that’s left is to click the Publish button, and we’ll have our Sitecore environment all up-to-date with the latest and greatest code!
Awesome. So now I have my code online – but oh no, an error. How can I debug this, when I just get a simple yellow screen? Well, first of all you could dive into the logfiles to get some more information. In addition I could turn off remote errors, but neither of those might actually tell me what’s happening within my code. What I’d really like to do is to start debugging. This first needs to be enabled in the Azure portal. You can find it in the Application Settings of your app service.
Simply set Remote Debugging in the Debugging section to On, and set your Remote Visual Studio version to the version you use. Alternatively, Visual Studio also asks if it can enable remote debugging if you skip setting it manually.
Then all that’s left is to publish your website with the Debug Configuration. In your Server Explorer in Visual Studio you can then right click on the Azure website and select Attach Debugger. The browser will then automatically open to the home page, so you might have to browse around a bit to find your error page :-).
Don’t forget to deploy your code using the Debug profile rather than the Release profile if you do want to debug.
PS. If any of your code has a dependency on the data folder, it has set it to the /App_Data folder by default.
It has been pointed out to me that we don’t actually need to download the publish settings from the portal. Instead, when creating a new Publishing Profile, click the ‘Microsoft Web Apps’ publishing target. Sign in the pop up window, and there’s an option to select a web app (or create a new one)
awesome walktrough Johannes, thanks for this!
Pingback: The brave new world of Azure PaaS | Jeremy Davis
Pingback: Zero downtime deployments with Sitecore on Azure | Bas Lijten
Pingback: Sitecore on Azure… With Unicorn | Sitecore and such
Pingback: Sitecore PaaS at Azure Marketplace – First Look | Edge Bytes