.NET Core HealthChecks si Migrarea aplicatiilor .NET ( clasic + core) in Azure

Prezentare 1: ASP.NET Core HealtCheck
Descriere : Monitorizare usoara a unui ecosistem ( PC, Drive , SqlServer, Jenkins, altele ) si adaugarea de HealthCheck custom la cerere.
Prezentator: Andrei Ignat, http://msprogrammer.serviciipeweb.ro/
Prezentare 2: Migrare .NET in Azure
Descriere:
Migrarea aplicațiilor ASP.NET cu .NET Framework 3.5/4
Migrarea aplicațiilor ASP:NET Core
Prezentator: Dragos Barbu , https://www.linkedin.com/in/drbarbu/

 

Online event : https://www.meetup.com/Bucharest-A-D-C-E-S-Meetup/events/271640830/

 

 

Update:

Presentation at:  https://ignatandrei.github.io/Presentations/NETCoreHealthChecksprez.html

Code at https://ignatandrei.github.io/Presentations/NETCoreHealthChecksprez.zip

Fun with Moniker- naming assembly versions

I liked the way docker generates names for every container instance – it was a funny way to differentiate them. I was thinking  – what about nuget packages – or any other release  ?

I have discovered Moniker – https://github.com/alexmg/Moniker . Can be used as in docker – to generate different names at various runs. However, what I wanted is to make every release to have a funny name.

I have put in .NET Core local tools ( see https://youtu.be/iHLRBxi4S7c  and the blog post http://msprogrammer.serviciipeweb.ro/2020/06/08/net-core-local-tools/ ) and I have used from powershell ( see https://github.com/ignatandrei/NETCoreBlockly/ for the usage)

First, I have created a variable

if($result -eq 0){

$moniker = “$(dotnet moniker -s moby)-$dateToPrint”

}

else{

$moniker = “$(dotnet moniker -s moniker)-$dateToPrint”

}

then used this variable in the release notes

$releaseNotes += (“;BuildNumber $env:BUILD_BUILDNUMBER with name “+ $moniker)

and in assembly title

dotnet-property “**/*.csproj” AssemblyTitle:”NetCoreBlockly $moniker”

Then, in C# , I write in the console:

static string nameBlockly()

{

var ass = Assembly.GetExecutingAssembly();

var assName = ass.GetName();

var nameBlockly = assName.Name;

try

{

var title = ass.GetCustomAttribute<AssemblyTitleAttribute>();

nameBlockly = title?.Title ?? nameBlockly;

}

catch

{

//do nothing

}

return $”{nameBlockly} version:{assName.Version.ToString()}”;

}

If you want to see in action , you can:

  1. Look at the nuget release notes at https://www.nuget.org/packages/NetCore2Blockly/ ( see BuildNumber … with name
  2. See the change log https://github.com/ignatandrei/NETCoreBlockly/blob/master/changelog.md – every release has the name
  3. Install NetCoreBlockly  and see the name 

Poor software developer simple changelog for CD

TL;DR; : Simple change log for Nuget Packages made with GIT Commands and Azure Devops

The NetCoreBlockly project have different versions on Nuget: https://www.nuget.org/packages/NetCore2Blockly/  . When I decide to put a new version on Nuget, it is enough to modify in the azure-pipelines.yml the

deployNuget: ‘0’

from 0 to 1 and AzureDevOps takes care of the rest ( including setting the version )

But I need also a changelog – something to show what is different between different versions .  If you want to do it properly, read https://keepachangelog.com/ and then find on some tool that enforces it ( for example, https://github.com/bzumhagen/dotnet-gitchanges  or https://www.npmjs.com/search?q=keywords:changelog )

For me, I wanted something simple, that generates the change log from the title of the commits . So this is my workflow

  1. Deploy the  nuget package
  2. Copy  the version from NuGet . In this case , 1.1.2020.13325959 ( the last number is trotal seconds from the stat of the year)
  3. Make modifications to come back to normal
    1. Tag the latest modif twith the version from NuGet
    2. Modify from 0 to 1 in azure-pipelines.yml
    3. Run the command  git log –pretty=format:”%n #### [%s] %n Author %an on %ai %n%n hash %h %H” 1.1.2020.12824981..1.1.2020.13325959 > a.txt
    4. Modify changelog.md with the results from a.txt
    5. Delete the a.txt file
    6. Commit/push to github

You can see the results at https://github.com/ignatandrei/NETCoreBlockly/blob/master/changelog.md

Generating outdated, licenses and thanks with .NET Core tools

Last time (http://msprogrammer.serviciipeweb.ro/2020/06/08/net-core-local-tools/) I have discussed about local tools . Now it is time to show something in practice, beside code coverage ( detailed http://msprogrammer.serviciipeweb.ro/2019/12/09/code-coveragepart-25/ and video https://youtu.be/JvahoA0WWms  ) ,

Let’ make something simple: generate outdated packages list, licenses and thanks.

I will use this packages

“dotnet-project-licenses”: {

“version”: “2.1.0”,

“commands”: [

“dotnet-project-licenses”

]

},

“dotnetthx”: {

“version”: “0.2.0”,

“commands”: [

“dotnet-thx”

]

},

“dotnet-depends”: {

“version”: “0.4.0”,

“commands”: [

“dotnet-depends”

]

},

“dotnet-outdated”: {

“version”: “2.11.0”,

“commands”: [

“dotnet-outdated”

]

}

And I will make a github action to run  to generate the outdated, licenses and thanks

name: .NET Core

on:

push:

branches: [ master ]

jobs:

build:

runs-on: windows-latest

steps:

– uses: actions/checkout@v2

– name: Setup .NET Core

uses: actions/setup-dotnet@v1

with:

dotnet-version: 3.1.101

– name: Install dependencies

run: |

        cd src

        cd NetCore2Blockly

        dotnet restore

        echo ‘done restore’

        dotnet tool restore –add-source https://myget.org/F/natemcmaster/api/v3/index.json

        dotnet dotnet-project-licenses  -j  -i .

        echo ‘done project licences’

        dotnet dotnet-thx > thanks.txt

        echo ‘done thanks’

        dotnet dotnet-outdated -o outdated.csv -of csv

        echo ‘done outdated’

        dotnet pwsh copyToRoot.ps1

        cd ..

        cd ..

        echo ‘back to source dir’

– name: test

run: echo done

– name: run commit

run: |

        git config –local user.email “action@github.com”

        git config –local user.name “GitHub Action”

        git add –all

        git status

        git commit -m “generate thanks, outdate, licences” -a –allow-empty

shell: cmd

– name: Push changes

uses: ad-m/github-push-action@master

with:

github_token: ${{ secrets.GITHUB_TOKEN }}

The powershell file that copies everything is here:

Move-Item .\licenses.json ..\..\licencesNetCore.json

Write-Host ‘copied licenses.json ‘

Move-Item .\outdated.csv ..\..\outdatedNetCore.csv

Write-Host ‘copied outdated.csv ‘

Move-Item .\thanks.txt ..\..\thanksNetCore.txt

Write-Host ‘copied thanks.txt ‘

And  you can see the result at

https://github.com/ignatandrei/NETCoreBlockly/blob/master/thanksNetCore.txt

https://github.com/ignatandrei/NETCoreBlockly/blob/master/outdatedNetCore.csv

https://github.com/ignatandrei/NETCoreBlockly/blob/master/licencesNetCore.json

You can find also a list of tools here: https://github.com/natemcmaster/dotnet-tools

Andrei Ignat weekly software news(mostly .NET)

* indicates required

Please select all the ways you would like to hear from me:

You can unsubscribe at any time by clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.