ALM and DevOps practices with a sample .NET method hosted in Azure Function App.
TOC
- History of changes
- Overview
- Build Definition with VSTS
- Release Definition with VSTS
- Other Misc DevOps practices implemented
- Alternatives and potential further considerations
- Resources
- November 2017
- Implement CI definition as YAML file PR#5
- October 2017
- Update Microsoft.NET.Sdk.Functions to 1.0.6 and xunit to 2.3.0
- August 2017
- Implement https://aka.ms/armconditions for the first Staging/CD's VSTS task to avoid deploying Production if it already exists. We don't want to impact existing Production while we are taking care about Staging - - PR#4
- Add more operational protection with Resource Group Policies - PR#2
- Convert MSTest projects to xUnit - PR#1
- July 2017
- Initial setup.
The goal of this GitHub repository is to demonstrate and use DevOps practices by leveraging a very simple compiled .NET method on Azure Function Apps (this Function is just an HttpTrigger saying "Hello" to the name passed in the querystring parameter).
Locally you will need to make sure your Visual Studio 2017 has the Azure Functions Tools extension.
By opening the .sln with Visual Studio you should see the structure of the solution like this:
To be able to setup the Build and Release definitions within VSTS described in the section below, you will need a Team Services (VSTS) account. If you don't have one, you could create it for free here.
To be able to deploy the Azure services (Function App, Application Insights, etc.), you will need an Azure subscription. If you don't have one, you could create it for free here.
Details could be found here: Build - CI
Here are the DevOps practices highlighted within this CI pipeline:
- CI/Build triggered at each commit on the master branch
- Compile the .NET library
- Run Unit tests of the .NET method
- Infrastructure as Code with the ARM Templates and the PowerShell scripts
- Expose artifacts to be used then by the CD pipeline (.NET library, ARM Templates, PowerShell scripts and Integration tests dlls)
- Create a bug work item on build failure (assign to requestor)
Details could be found here: Release - CD
Here are the DevOps practices highlighted within this CD pipeline:
- CD triggered at each CI/Build succesfully completed
- Deploy the Infrastructure as Code with the ARM Templates and the PowerShell scripts
- Deploy the .NET method on the Azure serverless service: Azure Function App
- Run IntegrationTests once the Function App is deployed on Staging
- Use the Staging Slot mechanism with the associated Swap action to minimize downtime while upgrading to Production
- Protect the production environment by adding a Lock and Policies on the associated Azure Resource Group
- Monitor the Function App by using Application Insights
- Have a dedicated VSTS Release Environment defined for Rollback automated actions.
- GitHub as source control to leverage key features for collaboration such as feature-branch with pull request, etc.
- CI/CD definitions as Code with the exported yaml/json file of the Build and Release Definitions respectively
- Improvements
- Instead of allowing 'anonymous' request, setup another AuthorizationLevel for security reason. There is an associated known issue logged here. See my associated stand-by PR#3.
- Configure VSTS and Microsoft Teams (or Slack or HipChat, etc.) to add more collaboration by setting up notifications once a work item is updated, a commit is done, a build or release or done, etc.
- Instead of just having a Production environment with its staging slot, having a QA environment with its associated staging too.
- Alternatives
- Instead of having a compiled .NET method/library, use static files with C#, NodeJS, etc.
- Instead of hosting the Azure Function App in a Consumption Plan, host it in an App Service Plan.
- A day in the life of an Azure serverless developer
- Create your first function using Visual Studio
- Automate resource deployment for your function app in Azure Functions
- Serverless computing with Azure Function in a DevOps Model
- Deployment Slots Preview for Azure Functions
- Application Insights integration with Functions now in preview
- Deploying Azure Function App with Deployment Slots using ARM Templates - Blog series: First, Second and Third
- Is Your Serverless Application Testable? – Azure Functions
- Azure Functions Proxies Sample
- Azure Functions - Samples and Content