19
How Azure can help your company expand in multiple regions (4 of 5)
In a previous article, you were guided through the benefits of running an Azure App Service application in multiple regions. Now that the cloud part of your application is ready, we can move forward setting up Azure DevOps.


Now that your projects are ready to go, it is time to configure Azure Repos to use the Git flow development model.
First, you must initialize the repository. This procedure will create a .git subdirectory containing metadata like refs, objects, and a HEAD file. The HEAD file points to the checked-out commit.

I can now move forward with implementing the Git flow development model. First, I am going to create the branches expected by this model:

The branches and bases are:

To require approval for a pull request, enable the Require a Minimum Number of Reviewers policy and define the Minimum Number of Reviewers. Repeat this procedure for the main, develop, and release branches.
When a pull request is approved, the approver can delete the source branch after merging. By default, this option is disabled. However, a mistake might result in the deletion of one of these critical branches. To disable this option, making the workflow more secure, you must do take the following steps:

In the securities pane that will appear, select the development team’s groups than set the Force Push property to Deny.

Repeat this procedure for the development and release branches.
Now that the branches, policies, and securities are properly configured, we can proceed by cloning the repository onto your local machine:

$ git clone https://[email protected]/GTRekter/Training/_git/Training
Cloning into 'Training'...
remote: Azure Repos
remote: Found 3 objects to send. (14 ms)
Unpacking objects: 100% (3/3), 739 bytes | 20.00 KiB/s, done.
According to the Git Flow model and the branch protection policies we have instituted, you must branch off a new branch with the following pattern feature- of the develop branch in order to push your development.
$ git branch
* main
$ git checkout --track origin/develop
Switched to a new branch 'develop'
Branch 'develop' set up to track remote branch 'develop' from 'origin'.
$ git branch feature-amazingfeature
$ git branch
* develop
feature-amazingfeature
main
$ git checkout feature-amazingfeature
Switched to branch 'feature-amazingfeature'
Now that we have set up the local environment, we can move forward with the development.
Because the bare development of the application is out of the scope of this article, we will create and publish a default .NET 5 web application for demonstration purposes.
$ dotnet new web -f net5.0
The results is the following tree:
.
├── Program.cs
├── Properties
│ └── launchSettings.json
├── README.md
├── Startup.cs
├── Training.csproj
├── appsettings.Development.json
├── appsettings.json
└── obj
├── Training.csproj.nuget.dgspec.json
├── Training.csproj.nuget.g.props
├── Training.csproj.nuget.g.targets
├── project.assets.json
└── project.nuget.cache
Before pushing the application to the remote repository, create a solution file and add the web application project to it.
$ dotnet new sln
$ dotnet sln add .\Training.csproj
Now it is time to push your code to the repository:
$ git add .
warning: LF will be replaced by CRLF in appsettings.Development.json.
The file will have its original line endings in your working directory
$ git commit -m "Starting commit"
[feature-amazingfeature 98d4c6d] Starting commit
11 files changed, 311 insertions(+)
create mode 100644 Program.cs
create mode 100644 Properties/launchSettings.json
create mode 100644 Startup.cs
create mode 100644 Training.csproj
create mode 100644 appsettings.Development.json
create mode 100644 appsettings.json
create mode 100644 obj/Training.csproj.nuget.dgspec.json
create mode 100644 obj/Training.csproj.nuget.g.props
create mode 100644 obj/Training.csproj.nuget.g.targets
create mode 100644 obj/project.assets.json
create mode 100644 obj/project.nuget.cache
$ git push --set-upstream origin feature-amazingfeature
Enumerating objects: 16, done.
Counting objects: 100% (16/16), done.
Delta compression using up to 8 threads
Compressing objects: 100% (14/14), done.
Writing objects: 100% (15/15), 4.19 KiB | 1.40 MiB/s, done.
Total 15 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Analyzing objects... (15/15) (27 ms)
remote: Storing packfile... done (118 ms)
remote: Storing index... done (48 ms)
To https://dev.azure.com/GTRekter/Training/_git/Training
* [new branch] feature-amazingfeature -> feature-amazingfeature
Branch 'feature-amazingfeature' set up to track remote branch 'feature-amazingfeature' from 'origin'.
Now the feature branch with your code is on the remote server. Once the development of your feature is finished, you need to merge its content with that of the base develop branch. Because of the branch policies that we previously set up, you can’t perform a base git merge operation; you need to create a new pull request. To do so:




From the Complete Pull Request pane, you can decide the merge type, decide how to handle work items after merging, and delete the feature branch once the merge is completed.
IMPORTANT: The option to delete the branch is not available on the main, develop, and release branches because of the branch securities that we previously set up.
19