Thursday, March 3, 2022

Azure Cosmos DB

When to use NoSQL Database?

"If your transactional volumes are reaching extreme levels, such as many thousands of transactions per second, you should consider a distributed NoSQL database" - Microsoft, Cosmos DB documentation

Relational Database

Fixed Schema

Table based structure

Vertical scaling

Provides ACID guarantees (atomicity, consistency, isolation, durability)

Data normalization


NoSQL Databases

Fluid schema

Multiple structures (key-value, graph, document, wide-column)

Horizontal scaling and data partitioning for scalability

Provides BASE (basically available, soft state, eventual consistency) semantics

Non-normalized data


Cosmos DB Benefits

Provides extremely low latency

Provides SLA for throughput, latency, availability and consistency

Support replication

High availability

Enables elastic scalability

Supports multiple consistency options

Integrated Analytics

Region Support

Schema-agnostic

Automatic Indexing

Supports multiple SDKs


Supported Cosmos DB API's

SQL (store data as json data) (container entity - Table)

Cassandra (CQL) (container entity - Table)

MongoDB (container entity - Collection)

Gremlin (Graph database - commonly used in product recommendation and social networks to denote the relationship between items) (container entity - Graph)

Azure Table (container entity - Table)


Throughput and Scaling

Vertical scaling - increase more resource, CPU, memory etc

Horizontal scaling - add more servers



Monday, February 28, 2022

Azure Functions

  • Needs storage account for creating Azure function
  • Runtime stack can be .net, java, node.js etc


Azure Functions can be hosted as 

  • Consumption plan (serverless - auto scale, has time limit of 5 minutes for each method invocation, pay per use)
  • Azure app service (no time limit, monthly plan service)
  • Premium plan (faster performance, reserved instances, enhanced security)
  • Docker container (on premises or any cloud provider)


Azure Function types

  • HTTP Function Triggers (web hooks, use for APIs invocation)
  • Timer Trigger (scheduled tasks, CRON expression)
  • Blob Storage Trigger (data operation, run when a new file is uploaded to Blob storage)
  • Queue Trigger (run in response to a message on a queue)
  • Cosmos DB Trigger (run when a document is created or updated)
  • Event Trigger
  • Graph Trigger
  • SendGrid Trigger (3rd party - send email)
  • Twilio Trigger (3rd party - send text)


Every Azure function has exactly one trigger


HTTP Request Trigger

Security considerations:

Anonymous (no key required)

Security key per function

Admin: key per function app


Input and Output Bindings

Example for Input Bindings:

Blob storage binding - read all contents of a file in Blob storage

Cosmos DB binding - look up a document in a cosmos DB database

Queue storage binding - read a message from queue

Microsoft Graph binding - access OneDrive


To develop locally, 

Azure Functions VS Code extension

we can use Azure storage emulator, Azure Cosmos DB Emulator

Command to run the function: func start

Call the endpoint using postman or powershell command "Invoke-WebRequest <endpoint>"

When a message is posted to a queue, we can use a free tool "Azure storage explorer" to view the queue and actual message


Azure Durable Functions (for workflows)

Create stateful, serverless workflows / orchestration

Orchestration Patters

Function Chaining

Fan-out Fan-in

Asynchronous HTTP APIs

Monitor pattern (Poll and sleep)

Human Interaction (Process approval / escalate)

Install Microsoft.Azure.WebJobs.Extensions.DurableTask nuget package



Thursday, February 24, 2022

Azure Service Bus

Azure Messaging Paradigms

  • Event Grid - Best suited for reactive programming (something happened here and somebody wants to know it)
  • Event Hubs - Telemetry and distributed data streaming
  • Storage Queues - just a queue. Once the messages are read, they will be removed from queue.
  • Service Bus

    • Multi tenant cloud message service that sends information between applications and services
    • Queue, Topics and Subscriptions
    • Publishers and Subscribers
    • Queues
      • Messages in the queue are ordered and timestamped on arrival. After that messages are saved safely in a redundant strategy so that it's not lost
      • The receiver has to ASK for message
    • Topics and Subscriptions
      • Pub/Sub pattern
    • Storage queue can grow more than 80 GB
    • Service Bus can grow only upto 80 GB
    • Service Bus guarantees FIFO, duplicate detection

  • Create Service Bus Namespace
    • eg: Mycompany.servicebus.windows.net
    • Pricing tier
    • Subscription
    • Resource group
    • Location
  • Primary Connection string (to connect to the bus)
  • Create queue
    • Queue Name
    • Size

  • Topics and Subscriptions
    • Subscribers are invoked or notified when a message of interest appears

Github Actions - CI/CD for React.js

 1. Install gh-pages npm package Command:  npm install gh-pages --save-dev 2. In package.json, add the homepage url "homepage": &q...