Showing posts from January, 2017

Azure Kudu Deployment with Version Number

I recently blogged about generating a version.txt file on every build via Visual Studio . This solution is fine if you are building from you local machine and using Web Deploy to deploy to Azure, but if you have a github webhook and are using kudu, the VS Post Build Events are not executed. The easiest way I found to generate a version.txt file for every deployment is to add a post deployment action  to your Web App/App Service. Create a file within the /site/deployments/tools/PostDeploymentActions/ folder of your App Service (you may need to create that folder). You can name the file whatever you'd like, I chose `generategitversionfile.cmd`. The file should contain at least the following line: git rev-parse HEAD > "..\wwwroot\version.txt" This command will be executed within the context of the `/site/repository` directory, that's why we need a more fully qualified path for where to write the file. Now, after every kudu deploy, a new version.txt file wil

Stop Azure WebJob from Azure WebSite

I recently had the need to toggle the status of an Azure WebJob from the WebSite in the same Azure App Service. I found a couple half-complete answers online, but I thought I'd put together this simple guide to have a complete example all in one place. To accomplish this, we'll be using the kudu REST API  for WebJobs . (note: I also looked into toggling the WEBJOBS_STOPPED environment variable from the WebSite, however I was not able to verify that solution was going to work. I confirmed I was able to set the environment variable from the website, however the value did not update in the "Application Settings" section of the Azure Portal and I was concerned the WebJobs may read a separate environment variable than the WebSite [process scoped vs machine envar for example]) The first thing you'll need to do is download the PublishSettings file (aka "Publish Profile") associated with the App Service (you need the username/password from this file to s

Version your Visual Studio Builds by Git Commit Hash

Semantic versioning is great, but more often than not, when I'm looking at a folder of deployed binaries, I want to know the git  commit   hash of the source code that was used to generate them (a versioned container might be better in some cases, but that's not applicable in every situation at the moment). A simple way to accomplish this is to generate a "version.txt" file at build time that will eventually be deployed with the code. Visual Studio makes it pretty easy to automatically generate this version.txt file with it's built in " build events ". Simply add the following line to the "Post-build event command line:" textbox, and a version.txt file will appear in your build output directory with the current commit hash after a successful build. "C:\Program Files\Git\bin\git.exe" rev-parse HEAD > "$(ProjectDir)$(OutDir)version.txt" If you'd like to generate this file after an Azure Kudu deployment, se

Replace Azure Scheduler with Azure Functions

I have written before about the shortcomings of the Azure Scheduler  (doesn't integrate with classic [non-RM] Azure Storage accounts, message body pushed to Azure Storage Queue is wrapped in XML, costs $15/mo for basic scheduling tasks...) but the good news is, now with Azure Functions , your Scheduler Tasks can mostly be replaced with Functions. Here are a couple tables to break down the differences in Triggers and Actions. Scheduler Triggers compared to Function Input Bindings Scheduler Functions Manual X X Timer X X Http X Storage Queue X Service Bus Queue X Service Bus Topic X Blob X Event Hub X Scheduler Actions  compared to Built-in Function Output Bindings   Scheduler Functions Http X X Storage Queue X X Service Bus Queue QuickFacts Data Set

To create a visualization for  I had to compile census information from the QuickFacts tool. As for as I could tell, they don't provide an easy way to automatically download all the data, so I manually downloaded each state then used a simple node script to merge them together. Data set available here: Hope this helps, Aaron

Azure Functions and AWS Lambdas

I'm working on a new talk about Azure Functions and AWS Lambdas . I'm writing this blog post to compile a list of links to more information for people that attended the talk. Presentation Slides: Azure Function Intro Source Code: Azure Intro Web App Source Code: Azure Function Tools for Visual Studio: AWS Lambda C# in Visual Studio: I'll add more links and update the slides as I continue to build out the talk. Hope this helps, Aaron