Getting Started With Azure DevOps

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Getting Started with Azure DevOps

© KC Martin
www.kevsbooks.com
Before we get going you may already know about Azure, of not here is a
brief introduction. Microsoft Azure, commonly referred to as Azure, is
a cloud computing service created by Microsoft for building, testing,
deploying, and managing applications and services through Microsoft-
managed data centres. The service provides software as a service
(SaaS), platform as a service (PaaS) and infrastructure as a service (IaaS) and
supports many different programming languages, tools, and frameworks,
including both Microsoft-specific and third-party software and systems.
To sign-up or sign-in to Azure simply go to this URL and get yourself sorted.
https://portal.azure.com/. For general information about the services try this
URL https://azure.microsoft.com/en-gb/ also. For the purpose of this
demonstration I will be linking with my stored code at Azure DevOps
(dev.azure.com/myAccount/), you may also have such an account if not why
not sign up for one, it is free.
Here I will walk through the steps that will show you the true power of the
dark side, sorry I mean Azure DevOps. If the then feel the desire to learn this
further there are plenty of books and websites that can offer a lot of good,
helpful information on this subject.
So once you are all setup and ready to go follow my steps here or simply just
read through this document.
Step 1 – Create Storage Account. In your azure portal select this link.
Now either select from the list or type in storage in the search box.

Then select storage account->Create.

Next click the Create new link

And type in a label of your choice. Then complete the page something like
mine below, try not to select Premium options unless you want to pay for
them.
Keep all other options as per default and step through to create, when
complete you will see a message like this.

If you then [Go to resource] you will see this page.

The resource will also appear on your dashboard.


Step 2. Create the container registry
Once again go to Create a resource. This time locate Container registry.

Select create and step through the process. Resource group should be the one
you created in Step 1. Then complete the remaining options.

Step through the remaining pages with default options and create.
Go to the resource to confirm.

Finally check the dashboard, you should see your new additions.

Step 3. In this step we need to enable Admin user in the Container registry
and create a Username with a password. So first select your Container
registry from your dashboard.

Then select Access Keys.


You will now need to enable Admin user.

When enabled a Username and 2 passwords will be created, make a note of


these before proceeding. Mine of course are hidden.

Step 4: Service Connections. For this step we now switch to the


dev.azure.com account. Below is the portal page for my setup.
From here I select “spicetheworld” and then project settings.

Followed by Service connections.

First we need a new Service Connection

On the next page you will probably be prompted to login to your Microsoft
account, this is standard procedure and nothing to worry about. Once logged
in you will be linked to you Azure account subscription. You will also be
able to selected the Resource group you created earlier.
Finally you will need to provide a Service connection name, the description is
optional, see next page for the screenshot.
Then click save, after a couple of moments your Service connection will be
created.
Now add a second Service connection, this time select type Docker registry.

Choose type Azure Container Registry, the rest is the same as before.

Step 5: In this step we now create the pipeline.


Select Use the classic editor

Next select your project, repository and branch.

Next you will select your template, this will be decided by the project type, in
my example it is ASP.Net Core because this matches my project.
To create click Save & queue->Save and Run. At this point you will have a
basic pipeline but now we need to enhance the functionality.

So now edit pipeline and add Docker build and Push. To do this click on the
+ link shown below.

Then select Docker, you may have to search for this option.

Select the Container registry and add the Container repository name.

The Docker file you select from the project repository.


To complete Select Save & queue->Save and run. When the run is complete
return to your portal and azure.com. From your dashboard select your
container registry.

For your information below is the contents of the Docker file.


FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /src
COPY ["spicetheworld.csproj", "./"]
RUN dotnet restore "spicetheworld.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "spicetheworld.csproj" -c Release -o /app/build

FROM build AS publish


RUN dotnet publish "spicetheworld.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "spicetheworld.dll"]

Next you need to select Repositories

Now you will see your repository.

Step 6: Now locate All Services->App Service for hosting.


And select Create app service. Complete like below and be sure to select the
Free Sku offering.

Continue to the Docker tab and also complete as below.

Everything else can stay as default so complete and save.


When complete save and wait for this message.
When deployed you will see an option to go to resource, select this and you
should see the service is running.

You will also notice a URL on the page, this is where your application will
reside should the deployment pass. In this case my test URL is
https://spicetheworlddev.azurewebsites.net/. This test site is not always up
but if you try it you may well see a page like that below, this was deployed
by DevOps.

Finally we need to enable continuous integration. This is done in 2 places.


First you need to return to your dev.azure.com account at locate your
pipeline.

Now click on the pipeline and then select Edit.


Go to the Triggers tab and enable continuous integration.

Then Save & Queue etc.


Next you return to portal.azure.com and locate your App Service.

Click on the App Service and select.

On this page you simply need to turn this option on.

From this point on every time you update your source code and submit the
changes the Continuous Deployment will kick in, the code will be built, unit
tests (if you have created them) will be run and if all goes well the updated
application will be deployed to your test server. Now that is cool.
So what you need to remember her is that now all of the services and
pipelines have been created your CI/CD DevOps should kick in every time
you commit code to your repository on the branch that you have setup during
this process. There is a lot more to DevOps than this but I hope this small
walk-through will give you a taste for what is possible.

You might also like