Azure Deployment of Mono-Repos in GitHub

sebnilsson

Seb Nilsson

Posted on April 29, 2020

Azure Deployment of Mono-Repos in GitHub

With the increasing adoption of Microservices, one of the questions sometimes discussed is mono-repo vs. multi-repo, which tries to answer if you structure your code to have one large, single repository for all/multiple microservices or individual, small repositories for each microservice.

If you're in the scenario of using a mono-repo, where you have multiple projects in a single repo, and you want to deploy this single code-base to multiple applications and services in Azure , there is a simple way to do this.

Kudu, the engine behind git-deployments in Azure App Service, has documentation on how to customize deployments, but only one of these ways works well with the mono-repo-scenario. The approach of using a .deployment-file unfortunately locks the configuration of the specified project into your source-code, so it won't work for mono-repos.

Instead, using the Application settings available in all Azure App Services, you use the key PROJECT to set the value for the path of the project you want to be deployed to your different Azure App Services. So this solution works for Function Apps, Web Apps, API Apps and much more.

Example

If you have the following code-structure in your single repository:

  • /src/ExampleProject/ExampleProject.csproj
  • /src/ExampleProject.FunctionsApp/ExampleProject.FunctionsApp.csproj
  • /src/ExampleProject.WebApiApp/ExampleProject.WebApiApp.csproj
  • /src/ExampleProject.WebApp/ExampleProject.WebApp.csproj
  • /test/ExampleProject.Tests/ExampleProject.Tests.csproj

Then you'd set up your PROJECT-path in Application settings for your different Application Services like this:

  • Function App : "src/ExampleProject.FunctionsApp"
  • Web App : "src/ExampleProject.WebApp"
  • API App : "src/ExampleProject.WebApiApp"

With the paths relative to the Git-repository's root-path. You can also point directly to the .csproj-file, if there is any risk of ambiguity in the same file-folder.

When this is done you can configure your Azure App Services for Continuous Deployment using the same repository , in GitHub, Bitbucket, local Git or any other source supported in Azure.

💖 💪 🙅 🚩
sebnilsson
Seb Nilsson

Posted on April 29, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related