Posts

Showing posts from December, 2022

Writing better Python code

Image
Image by https://www.pexels.com/@mikhail-nilov/ When we write code in any programming language, we tend to look into how code is written in the language. There are some guidelines and conventions that can help us to write better code and more readable code. There is even a term created for this in Python and it is Pythonic . In this blog, I share some of my points of view on writing better Python code. 1. Wildcards Imports  Sometimes, when we look at a function and we do not know where it is imported from. For example # bad practice to import all from math import * print(ceil(0.6)) This one is obvious however it is not when there are many imports and many lines of code in a file. A better way is # good practice to import what we need from math import ceil print(ceil(0.6)) 2. Unnecessary use of True and False This is not particular to writing code in Python as we have seen this in other programming languages too. names = ["ann", "beth", "candy", "d

Data Store

Image
Image from https://www.pexels.com/@tiger-lily/ Cloud providers offer different storage options catering to different needs. In this blog, we look at 3 data storage options provided by Azure . They offer the following Storage with Query Engine (Relational) Storage with Query Engine (Non-SQL) Storage without/limited query support 1. Storage with Query Engine (Relational) This is a cloud-based database service where the data is organized in rows and columns, and the schema for every table is well-defined. Azure SQL Server offers different deployment options. SQL Server on Azure VM (IaaS) Azure SQL Database (PaaS) Azure SQL Managed Instance (PaaS) I shall not attempt to dig deep into these options because many online resources are available. We choose this service because The data model is relational and well-defined high availability SQL supports Fast response time These are the cost considerations Deployment model Single Database deployed to an Azure VM Elastic Pool of databases,  Mana

Azure Managed Identity

Image
  Image by https://www.pexels.com/@cookiecutter/ In this blog, we discuss about the different options for service identity. Let's first lay down the objective of having a service identity for a service. In a typical landscape, we have service to service communication. The diagram below shows a function app needs to read and write to blob storage, call Azure Cognitive Service, Azure Cognitive Search and read from Azure SQL service. In this example, we need to authorize the function app to make requests to these services. In short, authorization is needed for service to service communication. To make thing simple, let's consider the case when we needed to authorize function app to read from a blob storage. Option 1: Connection String of Blob Storage Here, we set the connection string of the Blob Storage to a Azure Key Vault and have this string populated in function app's configuration. So that the function app can get it at runtime to read blob data. This option is not idea