Monday, 13 January 2020

Text to ASCII Art Generator Nuget

Create ASCII art from text with various settings like set text and background text with printing speed in .net. You might found various online Text to ASCII Art Generator, but now can do it by yourself in .net. Just Import TextToAsciiArt.dll and write some snippet and done!

Install-Package TextToAsciiArt -Version 1.0.0


Limitation: Only A-Z and 0-9 accepted.

Snippet:
using System;
using TextToAsciiArt;
class Program
{
    static void Main(string[] args)
    {
        IArtWriter writer = new ArtWriter();
 
        //1
        writer.WriteConsole("happy lohri 2020", null);
 
        //2
        var settings = new ArtSetting
        {
            ConsoleSpeed = 100,
            IsBreakSpace = true,
            Text = "|",
            BgText = "_"
        };
        writer.WriteConsole("happy lohri 2020", settings);
 
        //3
        var data = writer.WriteString("My name is Raj");
        Console.WriteLine(data);
    }
}
 

Output:


Running demo here.
Tags:

  • Text to ASCII Art Generator
  • Text Art
  • CMD Fancy Text
  • Console Text Art
  • Console Art

Friday, 10 January 2020

Create Azure CI/CD pipeline for building and deploying Azure Functions

In this post we will see, how we create an Azure CI/CD pipeline for building and deploying Azure Functions. We have already covered how we can create an Azure Function locally.

Now have a quick look on steps, which we will be performing here:

  1. Create Azure storage account in Azure portal: As AZ Function pricing is based on computation, we don’t have to pay much for running as long service. We can simply keep it in a storage account. Whenever any trigger would fire, it will start processing.
  2. Create an Function App in Azure portal: It will be treated as the service and we can define this service will be processing on which platform like OS or Container.
  3. Create CI build pipeline: To build and publish as zip artifact.
  4. Create CD release pipeline: To deploy artifact as service which we have created on azure portal.
  5. Verify function triggered successfully or not.


Let's see step by steps with images:

1. Create Azure storage account in Azure portal





2. Create an Function App in Azure portal





3. Create CI build pipeline




4. Create CD release pipeline








5. Verify function triggered successfully or not





Reference:
https://www.youtube.com/watch?v=zN0W2IPF1hI
https://www.asptricks.net/2018/11/azure-functions-basic-information.html


Friday, 3 January 2020

Create Azure CD release pipeline to deploy images on Kubernetes | Docker part 5

We already covered how to build and push Docker image to Docker hub or azure container registry through azure DevOps build pipeline. So we have:
  1. GitHub repo.
  2. Azure devops build pipeline with Container Build and Push tasks.
  3. DockerHub repository. (Public)
  4. Kubernetes service created and running.
Now what we have TODO now:
  1. Create deployment yaml file that required for Kubernetes deployment.
  2.  Add some more task in Build pipeline.
  3. Get Devops artifact.
  4. Create a Release pipeline.
  5. Deploy and verify pods on local Kubernetes dashboard.
Instead of doing TODO, if you want to deploy containers manually on Kubernetes you can follow YouTube video of Houssem Dellai.

Let's have a look on above TODO listed points, one by one. Special thanks to Microsoft Visual Studio, who described nicely on his YouTube video.

Create deployment yaml file that required for Kubernetes deployment.
Get the quick reference from Microsoft Official for creation of deployment file. And create simple kubernetes-deployement.yml in project folder with below content:

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: mysamplekubapps
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: demo-kub-apps
    spec:
      containers:
        - name: mssample-services-app
          image: rajkrs/docker_linux_redis_netcore:latest
          ports:
            - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
    name: demo-kub-apps
spec:
  ports:
    - name: http-port
      port: 80
      targetPort: 80
  selector:
    app: demo-kub-apps
  type: LoadBalancer


Add some more task in Build pipeline.
Because we will be regularly using build id as version variable, so let's create a variable

We want to change deployment file in such a way that, for each build image rajkrs/docker_linux_redis_netcore:latest would become  rajkrs/docker_linux_redis_netcore:<1.100>

So we are adding one CLI script task that will take care of latest version replacement.


Get Artifact.
And will publish changed deployment yml as artifact.

Create a Release pipeline.
We just create a release pipeline and assign the source build pipeline which we have created earlier.




To create Kubernetes service connection, click on New


Make sure in above image we have correct Manifests *. 

Now we have created the release pipeline, you may enable continues deployment  from Artifacts trigger option.


Deploy and verify pods on local Kubernetes dashboard.
Let's got to build and Queue one new build. Verify build completred.


Verify we have pushed tag 1.100 in Dockerhub.
Verify release pipeline is in progress..


Verify release completed successfully.

Verify we have Pods in Kubernetes.

Verify app had assigned with external IP: 52.154.232.146:80


And we are able to browse app. 🙂


Don’t forgot to verify azure subscription credit. 🤯









Thursday, 2 January 2020

Create Azure Kubernetes service and view dashboard | Docker part 4

Where by Using Docker, We build and run containers, and store and share container images.

There by using Kubernetes we orchestrates and manages the containerized applications that Docker creates. It also provides the infra needed to deploy and run those applications on a cluster of machines. Know more about Kubernetes here on Microsoft Official.





Let's know simple steps by following which we will be create Kubernetes serves and kubernetes dashboard.
Kubernetes dashboard will run locally.










PS C:\Users\raj.kumar1> az login
You have logged in. Now let us find all the subscriptions to which you have access...
[
  {
    "cloudName": "AzureCloud",
    "id": "88b268f4-b6e6-432a-84c7-64cc125a9f11",
    "isDefault": true,
    "name": "Free Trial",
    "state": "Enabled",
    "tenantId": "0fec8578-a553-4c8f-839b-a6d83f5932a3",
    "user": {
      "name": "mr.raj111@hotmail.com",
      "type": "user"
    }
  }
]

PS C:\Users\raj.kumar1> kubectl create clusterrolebinding kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard

clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created

PS C:\Users\raj.kumar1> az aks get-credentials --resource-group FreeKubernetesResource --name KubApps
Merged "KubApps" as current context in C:\Users\raj.kumar1\.kube\config

PS C:\Users\raj.kumar1> az aks browse --resource-group FreeKubernetesResource --name KubApps
Merged "KubApps" as current context in C:\Users\RAJ~1.KUM\AppData\Local\Temp\tmp3_vvoxr5
Proxy running on http://127.0.0.1:8001/
Press CTRL+C to close the tunnel...



Wednesday, 1 January 2020

Create Azure CI Build pipeline to create container & push image in DockerHub or Azure Container Registry | Docker part 3

Simple steps to build image and push through Azure Devops Build pipeline:
  1. Create a new build pipeline form Use the classic editor.
  2. Select a source from GitHub and choose repository after authentication.
  3. Choose a template Docker Container.
  4. Configure Build and Push task.
  5. Save and Queue.












If you are getting bellow problem,
denied: requested access to the resource is denied
##[error]denied: requested access to the resource is denied
##[error]/usr/bin/docker failed with return code: 1
Solution:
In the Build and image and Push an image make sure you have given fully qualified name
Image Name *: rajkrs/docker_linux_redis_netcore:$(Build.BuildId)