Moving an Azure DevOps repo to use Github Actions instead

In this blog post, I am going to take an existing web application that resides in Azure DevOps and port it to build and deploy within GitHub and use GitHub Actions to build and deploy the same site to GitHub.

Here you can see I have a website in Visual Studio which is currently pointing at a repository inside Azure Devops.

And here is what it looks like inside Visual Studio 2019 with the connection to Azure DevOps.

Now I am going to remove the connection from the Azure DevOps repo by clicking on remove like so:-

When I click on remove, this removes the connection from the code to the Azure DevOps repository. Then I go to the Sync area and it now asks me where do I want to push the code to.

This time I choose to Publish to GitHub.

Give the new repository a name (for within GitHub) and press Publish

This will push the code to a new GitHub repository called AzureGlobalBootCamp2020 which you can now see below.

Now we need to create a GitHub Action so that the code is built and pushed to Azure (like it was from within Azure DevOps previously).

From within your new GitHub repo click on Actions at the top.

I then chose Setup a new workflow yourself

This will take you to a screen and create a main.yaml file.

name: Deploy ASP.NET Core app to Azure Web App

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - '*'
# CONFIGURATION
# For help, go to https://github.com/Azure/Actions
#
# 1. Set up the following secrets in your repository:
#   AZURE_WEBAPP_PUBLISH_PROFILE
#
# 2. Change these variables for your configuration:
env:
  AZURE_WEBAPP_NAME: AzureGlobalBootCamp2020     # set this to your application's name
  AZURE_WEBAPP_PACKAGE_PATH: '.'                 # set this to the path to your web app project, defaults to the repository root
  DOTNET_VERSION: '3.1.100'                      # set this to the dot net version to use

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:

      # Checkout the repo
      - uses: actions/checkout@master
      
      # Setup .NET Core SDK
      - name: Setup .NET Core
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: ${{ env.DOTNET_VERSION }} 
      
      # Run dotnet build and publish
      - name: dotnet build and publish
        run: |
          dotnet build --configuration Release
          dotnet publish -c Release -o '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/myapp' 
          
      # Deploy to Azure Web apps
      - name: 'Run Azure webapp deploy action using publish profile credentials'
        uses: azure/webapps-deploy@v2
        with: 
          app-name: ${{ env.AZURE_WEBAPP_NAME }} # Replace with your app name
          publish-profile: ${{ secrets.azureWebAppPublishProfile  }} # Define secret variable in repository settings as per action documentation
          package: '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/myapp'

# For more samples to get started with GitHub Action workflows to deploy to Azure, refer to https://github.com/Azure/actions-workflow-samples

I then pasted this into the main.yaml file and changed the following:-

AZURE_WEBAPP_NAME: AzureGlobalBootCamp2020
DOTNET_VERSION: ‘3.1.100
publish-profile: ${{ secrets.azureWebAppPublishProfile }}

The last entry above publish-profile requires you to create a new secret in GitHub under Settings -> Secrets and call it azureWebAppPublishProfile and you need to paste in the publishing profile from your Azure Web App

The above screen shows me in the Azure Portal and I’ve clicked into my Azure App Service and when I click on Get Publish Profile it downloads the content of the Publish profile which I paste into the new Secret with GitHub.

And with that we are done, GitHub will kick off the GitHub Action and built and deploy my web app changes when I publish any change to GitHub right into Azure for me.

Note
To read more on using GitHub Actions with .Net you can read more on GitHub here -> https://github.com/actions/setup-dotnet

Feel free to comment below if this is useful or if you have any feedback etc.



Hosting your blog on Github Pages using Hugo

If you want to create a new blog / or want to host your blog site then it’s worth taking a look at Hugo.

Hugo is a free static site generator.

You can install Hugo by following these steps from the docs: –
https://gohugo.io/getting-started/installing/

Once installed you can run your content locally first which means you create content and see the change with a live reload – instant feedback on your changes which means you can create content to your liking rapidly.

The content is created using markdown and if you’re looking for a nice tool to help with markdown I was recommended to take a look at stackedit.io https://stackedit.io/app#, but tools like Visual Studio Code offer this also.

I am going to assume that you have installed Hugo and have some content.

To run the website locally type hugo server

This normally shows you a screen like so:-

We can see the url to use (highlighted in red) so grab this url http://localhost:1313/ and paste it into your favourite browser and there you can see your new creation. (Keep updating the content and testing it out until your happy with all of the content.)

If your planning on hosting your site using GitHub Pages (you need a GitHub Pro licence) then you need to make a small change to the config of your Hugo site, locate the config.toml file within the root and add in the following line just before the [params] section (normally line 8 maybe 9)

publishDir = “docs”

For the cloudfamily.info project which we host on GitHub Pages our config.toml file looks like this

This file and all our code for reference can be found at https://github.com/CloudFamily/CloudFamily/

Note:-

Before we added the change to the config.toml the code would be compiled into the newly created public folder,

If your planning to host your Hugo site on Azure then come back for part 2 and I’ll show you how to host your new blog using Hugo on Azure.

I’m going to assume if you’ve gotten this far Hugo has perhaps sparked some interest, or you’re looking into moving to use GitHub Pages.

One your happy it’s time to deploy this to GitHub Pages which will host your site for as a little as $7 a month (you need GitHub Pro) – checkout pricing for more information.

Create a new repository in GitHub and upload all of your content from the root (including the docs folder, p.s. assuming you’re still pushing to GitHub Pages).

To activate GitHub Pages with the new repository you need to go to the Settings section within your new repository and make the same change as in the image below. (change the source drop-down to point to the /docs folder)

Once you have completed that step, you need to go back to the root of your repository within GitHub and look for the environments link like the image below: –

This is where the GitHub Pages are compiled and built essentially, click on this link and you’ll see the latest code being built like so: –

And once that passes, click on View deployment to see your new site in action.

Note: –

You may notice that there are some issues with the look of the site, there are 2 things to check in order to resolve.


Potential Issue 1

First, add your website URL from the browser into the top line of the config.toml file like so (changing out username and repository name for either the URL or your website name if you have a custom domain name).

baseURL = “https://<username&gt;.github.io/<repository name>/

So for the https://cloudfamily.info/ website our top line in the config.toml file looks like this:-

baseURL = “https://cloudfamily.info&#8221;

Once you make this change, go back to the command prompt or PowerShell and run the command from the root folder Hugo

This recompiles your changes, then cd into the docs folder and do the following:-

  • git add.
  • git commit -a -m “updating config.toml file”
  • git push -u origin master

Potential Issue 2

Depending on what theme you chose, you may have to add it in as a submodule, an example of this is if you chose the minimal theme then you have to run the following command from the root folder of your repo:-

$ git submodule add https://github.com/calintat/minimal.git themes/minimal
$ git submodule init
$ git submodule update

Once you make this change, go back to the command prompt or PowerShell and run the command from the root folder Hugo

This recompiles your changes, then cd into the docs folder and do the following:-

  • git add.
  • git commit -a -m “updating config.toml file”
  • git push -u origin master

That should be you up and running, just remember the following if you make changes and want them to be compiled and ran on your GitHub Pages: –

Go to the root folder within the command prompt or PowerShell

  • Type Hugo to compile
  • Change dir into the Docs folder and then
  • git add.
  • git commit -a -m “updating config.toml file”
  • git push -u origin master

Note – many thanks to people who have pointed me in the direction of Netlify and other tools, I’ll look at Netlify next and the next post will cover hosting a Hugo site in Azure.

Please get in touch if you have issues with Hugo.



Using GitHub Actions to deploy a .Net Web App

So I wanted to take a look into GitHub Action’s and deploy a .Net Web App, this is my first real look into them and will be blogging about them a lot more in the future, below are the steps I took to do this.

  • Create a basic .Net MVC Web App using .Net Core 3.1
  • Run the app and make sure all is working as expected.
  • Deploy this to Azure web app to Azure and check it runs ok.
  • I then go into my Resource Group, locate the app service and from the click on ‘Get publish profile‘ – download the file and keep handy.
  • Then I added the code to GitHub in a new repo which you can find here: – https://github.com/gsuttie/GHActionsWebApp1
  • Next, I need to create a secret from within GitHub, so once you have your code in a new repository within Github go click on Settings and then Security and click Add a new secret, call it azureWebAppPublishProfile if you want to use the YAML below.
  • Then I click on Actions and create my first workflow, I chose, Setup a workflow yourself.
  • And then from here – https://github.com/actions/setup-dotnet I used the YAML and pasted in so that my main.yaml file looks like this
name: Deploy ASP.NET Core app to Azure Web App

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - '*'
# CONFIGURATION
# For help, go to https://github.com/Azure/Actions
#
# 1. Set up the following secrets in your repository:
#   AZURE_WEBAPP_PUBLISH_PROFILE
#
# 2. Change these variables for your configuration:
env:
  AZURE_WEBAPP_NAME: dummywebsite     # set this to your application's name
  AZURE_WEBAPP_PACKAGE_PATH: '.'      # set this to the path to your web app project, defaults to the repository root
  DOTNET_VERSION: '3.1.100'           # set this to the dot net version to use

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:

      # Checkout the repo
      - uses: actions/checkout@master
      
      # Setup .NET Core SDK
      - name: Setup .NET Core
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: ${{ env.DOTNET_VERSION }} 
      
      # Run dotnet build and publish
      - name: dotnet build and publish
        run: |
          dotnet build --configuration Release
          dotnet publish -c Release -o '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/myapp' 
          
      # Deploy to Azure Web apps
      - name: 'Run Azure webapp deploy action using publish profile credentials'
        uses: azure/webapps-deploy@v2
        with: 
          app-name: ${{ env.AZURE_WEBAPP_NAME }} # Replace with your app name
          publish-profile: ${{ secrets.azureWebAppPublishProfile }} # Define secret variable in repository settings as per action documentation
          package: '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/myapp'

# For more samples to get started with GitHub Action workflows to deploy to Azure, refer to https://github.com/Azure/actions-workflow-samples
  • If you plan to use the Yaml from the above, mind and change the one setting which is AZURE_WEBAPP_NAME – I set this to dummywebsite so rename that to whatever your app service is called.
  • Save that, and then start your new GitHub workflow.
  • If all is well then your good to go, push a change to the web app and it should build and deploy automatically using your new GitHub Action.


Azure Weekly

Azure is an ever-changing platform, its amazing just how often its updated, it’s also really hard to stay up to date with the numerous new services and the changes to existing services.

It’s also very hard to keep abreast of all of the Azure news throughout the year, months and weeks.

Azure weekly is a great way to keep up to date with what’s new each and every week.

Azure weekly is brought to you by the folks from Endjin – they do a number of amazing things with Azure and are a company worth checking out.

They are up to week 264 at this time of writing this article, so what are you waiting for? – go find out what’s new recently, subscribe and don’t miss a thing going forward.

You can also contribute content to Azure Weekly, so if you have a blog post and have Azure content contact them and you may end up appearing in the weekly newsletter.

You can also follow Azure Weekly on twitter at @AzureWeekly

Please let me know what you think of Azure Weekly.


Tags:


Ignite the Tour Zurich

Speaking At Microsoft Ignite the Tour, Zurich

On March 4-5th I will be attending and speaking at the Ignite Tour, Zurich and will be talking about Deployment Practices for Greater Reliability as part of the Ops learning path.

Within the talk I will cover how to move toward a more reliable deployment of software and infrastructure as code, I’ll cover testing and talk about what good looks like and show some demo’s of what an up to date app deployment looks like using services like AKS and Azure Devops.

I have never been to Zurich and speaking at conferences was one of my goals for this year, I am really looking forward to seeing some friends during my trip and be able to present.

I have been using Presenter Coach which is built into PowerPoint if you use PowerPoint online and will record a quick demo of this if people think it would be worthhwile.

If you’re attending let me know and I will come and say hi, maybe even see you at my talk.

Any questions let me know in the comments below.



AzureCharts.com

I have been familiar with Azurecharts.com long before it was mentioned on twitter by Mark Russinovich who you are all hopefully following on twitter.

The site is written by Alexey Polkovnikov and is one I keep coming back to and always point people to. There is a lot of very useful links on here.

The site has a number of features that I wanted to cover and you can read about what it can be used for in the about page.

The main concept is that you can go here and see what is new in each area of Azure right down to the actual azure service itself and this is continually updated for you.

I wanted to cover the areas which I think are incredibly useful that you may have missed within the site, so lets dive right in.

Highlights
Highlights allow you to choose a job role and it will highlight the azure services most likely to be of interest for that role.

Overview
The overview lists all of the Azure services and you can click on each to be taken to the relevant azure docs page to learn more.

SLA
The SLA section shows you the SLA (service level agreement for Azure services which has an SLA.

Status
This screen shows us which services are Generally Available or in Preview.

Timeline
This screen shows us the timeline for when we can expect to see the feature rolled out to the particular region show for the service.

Regions
This screen allows us to compare services by region, and will shows us the timeline and the status for the service you click on.

Presence
Presence shows us how many regions the service you click on is present within and can show future availability stats for some services.

Solutions
Solutions are where you can choose a service and then from the drop-down at the top make a choice and it will take you to the docs for the selection you make – so for example, if I select the Azure Cosmos DB service I can then choose from the solutions drop down like so: –

Stories
Stories are where you can select an azure service and read customer stories on how they implemented the service and has some very interesting ideas and usages of the technology.

Fun
Within the fun screen there is an azure quiz and an azure menu covering starters, main dishes, and desserts, go take a look.

Summary
In summary, this is a great site with a tonne of useful information and one to share with your team or on twitter, etc. – huge thanks to Alexey for putting this together and keeping it up to date.



Microsoft Learn

Microsoft Learn in my eyes is highly under rated, I want to show you why there is more to it than you have probably realised.

Learning Paths
Learning paths are a great way to explore a topic, there are currently around 1000 learning paths, so what are you waiting for, there is something for everyone in there, which means you. #alwaysbelearning

Filter
You can filter your learning by –

  • Product
  • Roles
  • Levels
  • Type (Learning Paths or Modules)

Bookmarks
Bookmark your learning choices and come back to them, you owe it to yourself to have learning goals and to finish the learning path or module, don’t start it and leave it, become good at finishing and not good at starting.

Collections
Collections are where you can group your own collection of learning paths and modules which might relate to a specific learning goal you have. This is perfect if you are studying for an exam or want to know more about a more general topic like server-less as an example.

Achievements
If you complete a module within a learning path you earn points and badges along the way and you can see these listed under achievements which can be found under your profile and looks like so: –

I myself have realised I haven’t been using Microsoft Learn for a while and there is a lot of great new content which I am off to check out now.

Let me know which level your on – I’m currently on level 8.



Global Azure BootCamp 2020 – Glasgow Edition

Saturday April 25th, 2020 is the date for this years Global Azure BootCamp Glasgow edition, in conjunction with the Glasgow Azure user Group.

You can read about last year’s event and learn about whats involved and the format for the day, were looking for 6 speakers to come to Glasgow on April 25th and give a 60 minute talk on anything Azure related.


The call for speakers page to submit a talk is now open

The page for signing up to attend will go live Monday 20/01/2010.

We hope to see you there!



Azure Advent Calendar wrap-up

The #azureadventcalendar was a shared idea between myself and @pixel_robots

Some quick stats as I write this: –

15,800 thousand YouTube views
15,000 website views from over 120 countries
1,300 hours of videos watched
1,200 subscribers

We set out with the idea of asking the Azure community for 25 videos / blog posts with a Christmas theme, with the idea in mind that it would give people the chance to show off their skills, learn new skills and contribute back to the community over December.

We asked people via twitter who would like to contribute to this idea in the middle of September to give people time to decide if they could manage to contribute in December (a 20-30 minute video isn’t easy, especially towards that time of year).

Before we knew it we had more than 25 filled up and it was clear that this might be a bit more popular than first thought, we increased it to 50 and before you know it we had increased it to 75. In order to avoid too many duplicate subjects we decided to cap it at 75.

Wow! 75 videos/blog post contributions would be pretty amazing.

We considered several ideas but wanted to keep it simple: –

  • Anyone could contribute
  • We could have had advertisements but kept it without as it was a community project for the community by the community and this was important to us both.

I would create the website and keep that up to date daily, and chase people for content, Richard was looking after our YouTube channel and scheduling the videos to go out at midnight.

Richard also designed the logo which I loved the second I saw it and we decided to use this as the brand and he also created video thumbnails for each video for people to use on twitter, videos and blog posts.

Now the real reason this was successful was due to the contributors, we were both blown away by the quality of content from each contributor and the Christmas theme just made it pretty cool.

Richard and I both had our Twitter and LinkedIn full with tweets and articles with the above logo in it, very regularly throughout the month which was super cool to see.

Setup
The website was basic and I was updating it daily with links to blog posts and using a very simple .Net Web app, and using Azure DevOps to build and deploy the web app to Azure, I also made use of staging slots to deploy the changes, check the links etc worked and then swapped the staging slot for production – super easy to do and well worth it.

Richard had the YouTube channel setup with the logo and scheduled the videos to be released using a schedule which was pretty sweet. He also created a thumbnail for each video for the contributor to use as they saw fit.

Highlights
The highlights for me were many, but one that stands out for me personally was seeing people who had never taken part in something like this, some had never created a blog post, many had never created a video before.

The hard part of the project was chasing people for content, especially when it was mid December and everyone is busy!

To end this post I want to mention the next project which you should keep your eye on by Joe Carlyle and Thomas Thornton called the #AzureSpringCleanup – personally looking forward to see more azure community coming together and creating awesome new content.

Please leave any feedback you have on the #azureadventcalendar below.




Azure Resource GitHub Repository

I have started a GitHub repository for a place to put the following so that the community can benefit from resources I have came across from the community.

I’m looking for others to contribute to this so that the community has a place to find helpful info – please take a look, add your study guides, useful links and more in here and help grow the useful resources we come across.

If you have an Azure Exam Study guide let me know and I’ll add a link to it from the Exam folder to your blog or create a quick pull request.

If you have any useful Azure Resources which aren’t listed then please either let me know or create a quick pull request.

I’m gong to be adding to this over time throughout the year, I’m looking for contributors so we can grow this out to be something useful to a lot of people.

Link to the GitHub Repository:- https://github.com/gsuttie/AzureResources