Skip to main content

Blog

.NET Core, BenchmarkDotNet and string compare performance
·489 words·3 mins
dotnet dotnet
You have to choose between using string.compare or == to compare strings. How would you know which method performs faster? Today I’ll show you how to use BenchmarkDotNet with .Net Core to answer that question. Let’s start: Create a folder for your new project # Open a command prompt an run:
Accepting Azure Marketplace Terms with Ansible
·243 words·2 mins
azure devops ansible
Last May I wrote: Accepting Azure Marketplace Terms with Azure CLI and this time we’ll accomplish the same task with Ansible. Turns out that Ansible 2.6 comes with a handy new module: azure_rm_resource which lets you create, update or delete any Azure resource using Azure REST API. So I decided to take it for a test drive with the “Accepting Terms” sample.
Installing Azure CLI and Ansible on Ubuntu
·226 words·2 mins
azure devops ansible azure cli
I’ve been using Ansible and the Azure CLI every single day for the last 3 months. Non stop work editing playbooks and scripts with Visual Studio Code and running them on Ubuntu (WSL) on my Windows 10 machine. Turns out that because Ansible uses python version 2.7.12 and the Azure CLI uses python 3.6.5 you can make a mess if you get “creative” trying to install the tools instead of using the recommended commands:
At last: Network Policies in AKS with kube-router
·433 words·3 mins
kubernetes azure network policies
For ages I’ve been waiting for a way to enforce netwok policies on AKS, so last weekend while I was googling around, I found this hidden gem posted by Marcus Robinson: Enforcing Network Policies using kube-router on AKS and had to test the proposed solution. Prerequisites: Azure Kubernetes Service (AKS) deployed with HTTP application routing enabled. kubectl installed Create a service exposed throuh your AKS DNS Zone # Let’s start by deploying the following service to your Kubernetes cluster, by saving the following content to a file named dni-function.yaml and replacing [YOUR_DNS__ZONE_NAME] with the corresponding value of your service:
Simple Machine Learning with .NET Core Sample
·493 words·3 mins
dotnet machine learning
I think that more than a year and a half ago I read “Real-World Machine Learning” by Henrik Brink, Joseph Richards, and Mark Fetherolf. A book that is easy to read and goes “to the point”!!! I’m sure you know what I mean. At the time the only thing that prevented me from really enjoying the book samples was that there was no easy way to “translate” them to .NET Core.
Accepting Azure Marketplace Terms with Azure CLI
·136 words·1 min
azure devops azure cli
When you try to deploy a VM from the Marketplace using an ARM (json) template you’ll get an error like the one below in the case when you’ve not previously accepted the Legal terms for the image: [{"Legal terms have not been accepted for this item on this subscription. To accept terms using Powershell..."}] Accepting the Legal terms is something you have to do once per subscription for each provider offer you want to use. So how can you accept the terms using the Azure CLI (version 2.0.26 or higher)?
Running Ansible Azure playbook in Azure Cloud Shell
·150 words·1 min
azure devops ansible cloud shell
NOTE: The issue described in this post was fixed!!! (ansible 2.5.2 and Azure CLI 2.0.34) # Last week I tried to run this simple Ansible playbook in Azure Cloud Shell: # resource_group.yml # Create test resource group in west europe - name: Create a Resource Group hosts: localhost connection: local gather_facts: no tasks: - name: Create Resource Group azure_rm_resourcegroup: location: westeurope name: test state: present The first attempt to run the playbook with:
Adding Code Analysis and StyleCop checks to .NET Core projects with dotnet-addcasa
·123 words·1 min
dotnet static analysis
Today I’ll show you how to use dotnet-addcasa: a .NET Core global tool to add CodeAnalysis and Stylecop checks to your projects. If you want to manually add those checks or understand the tool internals check my post: .NET Core, Code Analysis and StyleCop Prerequisites # You’ll need .NET Core SDK 2.1.300-preview1 installed.
Using Docker Multi Stage Builds to build an ASP.NET Core Echo Server
·390 words·2 mins
dotnet aspnetcore docker
Today I’ll show you how to create a simple Echo Server with ASP.NET Core and then a Docker Image using multi-stage build: Create the Application # Open a PowerShell promt and run: mkdir echoserver cd echoserver dotnet new console dotnet add package Microsoft.AspNetCore -v 2.0.2 Replace the contents of Program.cs # Replace the contents of the Program.cs file with the following code:
Secure your Kubernetes services with NGINX ingress controller, tls and more.
·994 words·5 mins
kubernetes azure nginx ingress conroller
Disclaimer: samples provided in this post were tested both in Azure Container Services (AKS) and Kubernetes provided by Docker for Windows. In previous posts I showed you how to Run a Precompiled .NET Core Azure Function in a Container and how to Deploy your first Service to Azure Container Services (AKS). By now you should be able to run your own services in Kubernetes and starting to wonder about how can you give answers to questions such as:
My kubectl Cheat Sheet
·195 words·1 min
kubernetes cheat sheet kubectl
This is a small kubectl Cheat Sheet with the list of commands and settings I use, almost on a daily basis, when working with kubernetes. Get version and cluster information # Get kubectl version # kubectl --version Get cluster information # kubectl cluster-info Check cluster nodes # kubectl get nodes Get running services # kubectl get services -w --all-namespaces Context # List all available contexts # kubectl config get-contexts Get current context # kubectl config current-context Change the context # kubectl config use-context [context name] Deployment # Deploy # kubectl apply -f [yaml definition file] Get deployment definition # kubectl get deployment [deployment name] -o yaml Update the image of a deployment # kubectl set image deployment/[deployment name] [container name]=[image tag] Set autoscale for a deployment # kubectl autoscale deployment [deployment name] --min=2 --max=5 --cpu-percent=80 Delete a deployment # kubectl delete -f [yaml definition file] Get secret definition # kubectl get secret [secret name] -o yaml Force delete a pod # kubectl delete pod [pod name] --grace-period=0 --force Logs # Read a pod’s log # kubectl logs [pod name] -n [namespace name] Misc # Install kubernetes dashboard # kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml Hope it helps!
Microsoft MVP Global Summit 2018 Experience
·375 words·2 mins
azure dotnet mvp
Disclaimer: For those of you who are expecting to learn or read about new technical information and cool new product features or roadmaps I have bad news: almost everything that Microsoft shares with MVPs during the Summit is under an NDA (Non-Disclosure Agreement) which means that what I’ve learned in Redmond stays with me, inside my head.
Consuming Azure Event Hubs Events With Kafka Connect
·315 words·2 mins
azure kafka kafka connect eventhubs
So last week I was in a rush to find a fast and easy way to consume events from Azure Event Hubs and send them to a Kafka topic. After googling a bit I found this project: Kafka Connect Azure IoT Hub. Yes the name of the project can be misleading, but since IoT Hub is a service which relies on Event Hubs and also taking a close look to the code showed that it uses the Event Hubs client for java, I decided to give it a try.
Run a Durable Azure Function in a Container
·830 words·4 mins
azure dotnet docker azure functions serverless
Greetings readers! Hope you all a Happy New Year! Last post I was about running a Precompiled .NET Core Azure Function in a Container. This time let’s go one step further and Run a Durable Azure Function in a Container Prerequisites: Docker installed and basic knowledge. .NET Core Azure Storage Account Azure Durable Functions Knowledge Create a .NET Core lib project # Create a .NET Core lib project.
Run a Precompiled .NET Core Azure Function in a Container
·651 words·4 mins
azure dotnet docker azure functions serverless
So this morning I found my self browsing through the images Microsoft has published in the Docker Hub and then I saw this one: microsoft/azure-functions-runtime and decided to Run a Precompiled .NET Core Azure Function in a Container. Prerequisites: Docker installed and basic knowledge. .NET Core Create a .NET Core lib project # Create a .NET Core lib project.
Deploy your first Service to Azure Container Services (AKS)
·550 words·3 mins
azure kubernetes docker aks
In this post I’ll show you how to Deploy your first Service to Azure Container Services (AKS). Prerequisites: Azure CLI installed and basic knowledge experience. Docker installed and basic knowledge. Azure Subscription Kubernetes experience. Create a resource group: # Firt create a Resource Group. Be aware that at the time of writing AKS is not available in all Azure regions.
Use PowerShell to create a Microsoft Teams Channel
·159 words·1 min
devops powershell microsoft teams
For those of you who have been trying to automate anything related to Microsoft Teams, let me tell you that there is a new PowerShell Module in town: Microsoft Teams 0.9.0 which you can install with the following command: Install-Module MicrosoftTeams Now to automate the channel creation In A Team you can simply:
Use PowerShell to enable Azure Storage Account Firewall Rules
·157 words·1 min
azure devops storage account powershell
In this post I’ll show you how to Use PowerShell to enable Azure Storage Account Firewall Rules. Be sure to be have AzureRM PowerShell 4.4.1 module installed. Login to your Azure Account # Launch Powershell and start by Login to your Azure Account.
Use PowerShell to Enable and Automate Azure Analysis Services Backup
·605 words·3 mins
azure devops analysis services backup powershell
In this post I’ll show you how to Use PowerShell to Enable and Automate Azure Analysis Backup. Enable Azure Analysis Service Backup # Enable-AzureRmAnalysisServicesBackup is a small powershell script that uses the the Set-AzureRmResource cmdlet to enable backup location to an Azure Analysis Service instance.
Prepare a .Net Core Console App for Docker
·248 words·2 mins
dotnet docker
Last week I had the luck to attend the Microsoft Azure OpenHack in Amsterdam. We spent two and a half days learning a lot about kubernetes, Azure Container Services, Azure Container Registry, Azure OMS and Minecraft! In one of the challenges we decided to implement a sidecar container for logging purposes. So using .NET Core we created a console application with proper handling of the"Control+C" and"Control+Break" key shortcuts.