MSBuild Task to Mark Azure Git Deployment in Rollbar
I prefer using git to deploy to Azure: it’s great that a production deployment is
only a git push azure master away. Git deployment comes with a number of
benefits like making it easier to rollback, forcing you to always commit, and
making it hard to forget to deploy an asset.
As I’ve written before, I like using
Rollbar for collecting errors so they can be notified, triaged, and addressed.
Rollbar has the ability to mark a deployment so that you know which version of
the software is causing problems. All you need to do is POST to their API
passing along the environment and your access key.
Rollbar provides a link to a gist from
Matt Hensley showing how to read the values from
your web.config in order to make the API call.
Luckily, in Azure, any application settings you configure through the portal
are available as environment variables. If you create a setting called
RollbarAccessToken, it will be available to all processes as
I forked Matt’s
gist and simplified it to use the environment variables rather than reading
You can include it in your web project’s .csproj file by importing it:
<ProjectToolsVersion="12.0"DefaultTargets="Build"xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><ImportProject="..\packages\UmbracoCms.7.2.4\build\UmbracoCms.props"Condition="Exists('..\packages\UmbracoCms.7.2.4\build\UmbracoCms.props')"/><ImportProject="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/><!-- Include this line here --><ImportProject="..\Rollbar.targets"/><PropertyGroup><ConfigurationCondition=" '$(Configuration)' == '' ">Debug</Configuration><PlatformCondition=" '$(Platform)' == '' ">AnyCPU</Platform> ...
Now when you push to Azure, the build will trigger a notification in Rollbar.