Courses Job Ready Program Fresher Trainings AI For Class 7 to 12 Corporate Training Placements Tutorials
Free Learning Resources

IT Tutorials & Interview Prep

Free guides, interview Q&As, and job responsibility breakdowns — curated by industry veterans to help you crack MNC interviews

211+
Tutorial Articles
14
Topic Categories
100%
Free to Read
← Back to  Azure Administrator (AZ-104 )

Chapter 6 : Azure Files & Azure Cosmos DB

 Azure Administrator (AZ-104 ) Last Updated: Aug 18, 2026

6.1 Introduction to Azure Files

Azure Files is a cloud-based file storage service in Microsoft Azure that provides managed file shares. It allows users, applications, and Azure Virtual Machines to store and access files through standard file-sharing protocols such as SMB and NFS.

 

What is Azure Files?

Definition

Azure Files is a fully managed cloud file-sharing service in Microsoft Azure that provides shared file storage accessible from cloud and on-premises environments.

Explanation

Azure Files allows organizations to create File Shares inside an Azure Storage Account. These File Shares can be accessed by multiple users, applications, and Azure Virtual Machines.

It works similar to a traditional file server, but the storage infrastructure is managed by Azure. Organizations therefore do not need to maintain physical file servers for the file storage service.

Azure Files supports standard file-sharing protocols such as SMB (Server Message Block) and NFS (Network File System), depending on the storage configuration.

Azure Files Azure की एक managed cloud file storage service है, जिसका उपयोग files और folders को cloud में store करके उन्हें multiple users, applications और Virtual Machines के साथ share करने के लिए किया जाता है।

यह traditional file server की तरह काम कर सकता है, लेकिन इसमें physical file server की infrastructure को organization को खुद maintain नहीं करना पड़ता। Azure underlying storage infrastructure को manage करता है।

Example

Suppose a company wants to store common project documents in Azure.

It creates:

  • Storage Account: companydata
    File Share: project-files

The File Share can contain:

  • Project Reports
  • Documents
  • Excel Files
  • Application Files

Authorized users and applications can access these files.
 

इस example में companydata Storage Account है और project-files एक File Share है। इसी File Share के अंदर company अपनी files और folders को store कर सकती है।

 

Benefits of Azure Files

1. Fully Managed File Storage

Azure manages the underlying storage infrastructure, reducing the need to maintain physical file servers.

Organizations can create and manage File Shares directly through Azure.

 

2. Shared File Access

Azure Files allows multiple users, applications, and Virtual Machines to access the same File Share.

This is useful when several systems need access to common files.

 

3. Cloud-Based Storage

Files are stored in Azure rather than on a local physical file server.

This allows organizations to access their file storage from Azure-based environments and, depending on configuration, from on-premises environments as well.

 

4. Scalability

Azure Files can support organizations as their storage requirements increase.

Additional files and data can be stored without requiring the organization to purchase and install additional physical storage hardware.

 

5. Integration with Azure Services

Azure Files can be used with Azure Virtual Machines and other Azure services that require shared file storage.

This makes it useful for applications that need a common file location.

 

6. Support for Standard File Protocols

Azure Files supports standard file-sharing protocols such as SMB and NFS.

This allows applications and systems to work with Azure Files using familiar file-sharing methods.

 

Azure File Share

Definition

An Azure File Share is a shared storage location created inside an Azure Storage Account where files and directories can be stored and accessed.

Explanation

The Storage Account provides the storage service, while the File Share provides the actual shared file storage.

A single Storage Account can contain one or more File Shares.

For example:

Storage Account: companydata

File Shares:

  • documents
  • projects
  • backups

Each File Share can contain its own folders and files.

Example

Suppose a company wants to store common project documents.

It creates:

Storage Account: companydata
File Share: project-files

Inside the File Share:

  • Project-A
  • Project-B
  • Project-C

Different authorized users or applications can access the required files through the File Share.

 

Azure Files Use Cases

1. Shared Application Storage

Azure Files can provide a common file location that can be accessed by multiple applications or Virtual Machines.

For example, multiple application servers can access the same shared files.

 

2. File Server Migration

Organizations can migrate traditional on-premises file shares to Azure Files.

Instead of maintaining a physical file server, the organization can use an Azure File Share for cloud-based file storage.

 

3. Shared Documents

Azure Files can be used to store documents that need to be accessed by multiple users or systems.

For example, an organization can maintain shared folders for project documents, reports, and company files.

 

4. Application Configuration Files

Applications running on multiple Virtual Machines may require access to common configuration or data files. Azure Files can provide a shared location for these files.

 

5. Backup and Data Storage

Azure File Shares can also be used to store files and other data that need to be retained in Azure.

 

Azure Files Basic Structure

ComponentPurpose
Storage AccountProvides the Azure storage service
File ShareProvides shared file storage
DirectoryOrganizes files into folders
FileStores the actual data

 

Example

Storage Account: companydata

File Share: company-documents

Directory: Projects

Files: Project1.docx, Project2.xlsx

The Storage Account contains the File Share, and the File Share contains directories and files.

 

6.2 SMB File Share

SMB (Server Message Block) is an important protocol used with Azure Files to provide shared file storage. It allows users, applications, and Virtual Machines to access files and folders over a network in a way similar to a traditional Windows file server. Azure Files currently supports SMB 3.1.1, SMB 3.0, and SMB 2.1.

 

What is SMB?

Definition

SMB (Server Message Block) is a network file-sharing protocol used to access and manage files, folders, and other shared resources over a network.

Explanation

SMB follows a client-server model. A client connects to an SMB server or file share and can perform operations such as opening, reading, writing, modifying, and deleting files according to its permissions.

For example, in a traditional organization, a Windows file server may contain a shared folder such as:

\\FileServer\CompanyData

Users connected to the network can access this shared folder using SMB.

SMB is widely used in Windows environments because it supports network file sharing, authentication, permissions, and file operations.

[Complete Guide] How to Back Up vCenter with SMB Protocol

SMB (Server Message Block) एक network file-sharing protocol है, जिसका उपयोग network के माध्यम से files और folders को access और share करने के लिए किया जाता है।

उदाहरण के लिए, किसी company के File Server पर एक shared folder है। Users अपने computers से network के माध्यम से उस folder को access कर सकते हैं। इसी तरह Azure Files में भी SMB का उपयोग करके File Share को access किया जा सकता है।

SMB File Share

Definition

An SMB File Share is a shared file storage location that can be accessed over a network using the SMB protocol.

Explanation

In Azure, an SMB File Share is created as part of Azure Files. It provides a shared location where files and folders can be stored and accessed by authorized users, applications, and Virtual Machines.

For example:

  • Storage Account: companydata
    File Share: documents

The File Share can contain:

  • Reports
  • Projects
  • Invoices
  • Documents

A Windows client or Azure VM can connect to the File Share and work with the files using SMB.

Azure Files SMB shares can be accessed concurrently by many clients and are commonly used for end-user file shares and Windows-based application storage.

 

SMB File Share एक ऐसा shared storage location है जिसे network के माध्यम से SMB protocol का उपयोग करके access किया जाता है।

Azure में SMB File Share, Azure Files के अंदर बनाया जाता है। इसमें files और folders store किए जा सकते हैं और authorized users या applications इन्हें access कर सकते हैं।

SMB Versions

Definition

SMB Versions are different generations of the SMB protocol that provide different features, security capabilities, and compatibility with operating systems.

Important SMB Versions

SMB VersionGeneral Characteristics
SMB 2.1Older version with improved performance compared with SMB 1.0
SMB 3.0Introduced stronger security features such as encryption and improved performance
SMB 3.1.1Latest major SMB version supported by Azure Files, with additional security and encryption capabilities

Azure Files supports SMB 3.1.1, SMB 3.0, and SMB 2.1. Microsoft recommends using SMB 3.1.1 unless an application specifically requires an older version.

 

SMB के अलग-अलग versions समय के साथ विकसित हुए हैं। नए versions में security, performance और reliability बेहतर होती गई है।

Azure Files में SMB 3.1.1 सबसे modern supported version है। पुराने applications या operating systems की आवश्यकता होने पर older SMB versions का उपयोग किया जा सकता है।

 

How SMB File Share Works

Explanation

When a client wants to access an Azure SMB File Share, it establishes an SMB connection to the File Share.

The basic process is:

Client → Network → Azure Storage Account → SMB File Share → Files/Folders

The client sends requests to the File Share, such as opening or reading a file. Azure Files processes the request and returns the required data.

Access to the File Share is controlled through authentication and authorization. Azure Files supports identity-based authentication for SMB, and permissions can be applied at the share, directory, and file levels.

Example

Suppose a company has an Azure File Share: \\companydata.file.core.windows.net\documents

A user connects to the share from a Windows computer.

The user can then open: Documents → Reports → Sales.xlsx

If the user has the required permissions, the file can be opened, modified, or saved.

 

जब कोई client Azure File Share को access करता है, तो वह SMB protocol के माध्यम से File Share से connection establish करता है।

Client द्वारा भेजे गए requests, जैसे file open करना, read करना या write करना, SMB के माध्यम से Azure Files तक पहुँचते हैं। Azure Files request को process करके required data वापस client को देता है।

User को केवल वही files या folders access करने की अनुमति मिलती है जिसके लिए उसके पास appropriate permissions हैं।

 

Azure Files and SMB

Definition

Azure Files and SMB refers to using the SMB protocol to access Azure file shares as shared network storage.

Explanation

Azure Files supports SMB as one of its main file-sharing protocols. SMB is particularly useful for Windows-based environments, shared folders, and applications that already depend on traditional network file shares.

Azure SMB File Shares can be accessed from Windows, Linux, and macOS clients. They can also be used by Azure Virtual Machines and can be integrated with on-premises environments.

Azure Files also provides security features for SMB, including SMB channel encryption, identity-based authentication, and access controls.

Example

A company has an application running on several Azure VMs. Instead of storing separate copies of common files on every VM, the company can create an Azure SMB File Share.

The VMs can access the same File Share and work with the common files.

 

Azure Files में SMB का उपयोग करके Azure File Share को एक network shared folder की तरह access किया जा सकता है।

यदि किसी company के कई Azure VMs को एक ही files और folders की आवश्यकता है, तो एक common SMB File Share बनाया जा सकता है। सभी authorized VMs उस shared storage को access कर सकते हैं।

 

SMB File Share Example

Storage Account: companydata

SMB File Share: company-files

Inside the File Share:

  • Projects
  • Reports
  • Backup
  • Documents

Authorized users and Azure VMs can access these files through the SMB protocol.

इस example में Storage Account के अंदर एक SMB File Share बनाया गया है। Authorized users और VMs network के माध्यम से उसी shared storage को access कर सकते हैं।
 

6.3 Azure Cosmos DB Overview

Azure Cosmos DB is a fully managed, distributed NoSQL database service in Microsoft Azure. It is designed for modern applications that require low latency, high availability, flexible data models, and the ability to scale as the amount of data and traffic increases.

 

What is Azure Cosmos DB?

Definition

Azure Cosmos DB is a fully managed NoSQL database service that provides globally distributed data storage with flexible schemas, low-latency access, and elastic scalability.

Explanation

Unlike traditional relational databases that generally organize data into fixed tables and relationships, Cosmos DB is designed to work with flexible, semi-structured data, including JSON documents.

Azure Cosmos DB can distribute and replicate data across Azure regions. This allows applications to provide fast access to users in different geographical locations while maintaining high availability.

It also automatically indexes data by default, which helps applications query stored data without requiring extensive manual index management.

Azure Cosmos DB Azure की एक fully managed NoSQL database service है। इसका उपयोग ऐसे applications के लिए किया जाता है जिन्हें fast response, high availability, flexible data storage और large-scale data handling की आवश्यकता होती है।

इसमें data को traditional relational database की तरह fixed tables में रखना आवश्यक नहीं होता। यह JSON जैसे flexible data को store और query कर सकता है।

 

Why Azure Cosmos DB is Used

Definition

Azure Cosmos DB is used to build applications that require fast performance, high availability, flexible data storage, and large-scale data processing.

Explanation

Modern applications may have users from different locations and may experience sudden increases in traffic. A database must therefore be able to handle large numbers of requests while maintaining predictable performance.

Cosmos DB is designed for these requirements. It supports horizontal scaling, global distribution, and multi-region replication. Applications can therefore store and access data across multiple Azure regions.

For example, an international e-commerce application may have users in India, Europe, and the United States. Cosmos DB can distribute data across regions to provide low-latency access to users in different locations.

Azure Cosmos DB का उपयोग मुख्य रूप से उन applications के लिए किया जाता है जिनमें बहुत अधिक users, large amount of data, fast response और high availability की आवश्यकता होती है।

यदि application का traffic अचानक बढ़ जाता है, तो Cosmos DB अपनी scaling capabilities के माध्यम से बढ़ी हुई demand को handle कर सकता है।

 

Key Features of Azure Cosmos DB

1. Global Distribution

Cosmos DB allows data to be distributed across multiple Azure regions. This helps applications provide faster access to users in different geographical locations and improves availability.

Data को अलग-अलग Azure regions में distribute किया जा सकता है, जिससे अलग-अलग locations के users को data जल्दी मिल सकता है।

 

2. Low Latency

Cosmos DB is designed for applications that require fast read and write operations and predictable performance.

 Low latency का मतलब है कि application के request का response बहुत कम समय में प्राप्त हो।

 

3. Elastic Scalability

Cosmos DB can scale horizontally as data and application traffic increase. Throughput and storage can be scaled according to workload requirements.

Application में users या data बढ़ने पर Cosmos DB की capacity को भी बढ़ाया जा सकता है।

 

4. Flexible Data Model

Cosmos DB supports flexible, schema-agnostic data, making it suitable for applications where the structure of data can change over time.

इसमें data के लिए पहले से rigid structure define करना आवश्यक नहीं होता। इसलिए बदलती requirements वाले applications के लिए यह useful है।

 

5. Automatic Indexing

Cosmos DB automatically indexes data by default, helping applications query data efficiently without manually creating indexes for every property.

 Cosmos DB data को automatically index करता है, जिससे stored data को efficiently search और query करना आसान होता है।

 

6. High Availability

Cosmos DB supports multi-region replication and automatic failover capabilities to help applications remain available when a region or service endpoint becomes unavailable.

यदि किसी एक Azure region में problem आती है, तो replicated data और failover capabilities application की availability बनाए रखने में मदद करती हैं।

 

7. Multiple APIs and Data Models

Azure Cosmos DB supports different APIs and data models, including NoSQL, MongoDB, Apache Cassandra, Apache Gremlin, and Table.

Cosmos DB में अलग-अलग प्रकार के applications और data requirements के लिए multiple APIs उपलब्ध हैं।

 

Azure Cosmos DB Use Cases

1. Web and Mobile Applications

Cosmos DB can be used for web and mobile applications that require fast access to user and application data.

Example: A social media application can store user profiles, posts, preferences, and other application data.

Web और mobile applications में users की information और frequently accessed data को store करने के लिए Cosmos DB उपयोग किया जा सकता है।

 

2. E-Commerce Applications

Cosmos DB is suitable for applications that experience changing traffic and require fast access to product, customer, and transaction-related data.

Example: An online shopping platform can use Cosmos DB for product catalogs and user-related application data.

E-commerce applications में users और traffic बहुत तेजी से बदल सकते हैं। Cosmos DB ऐसे workloads के लिए suitable हो सकता है।

 

3. Internet of Things (IoT)

IoT applications can generate large volumes of data from devices and sensors. Cosmos DB can handle high-throughput workloads and large-scale data.

IoT devices लगातार data generate करते हैं। Cosmos DB ऐसे large-scale data और high-throughput workloads को handle करने के लिए उपयोग किया जा सकता है।

 

4. Gaming Applications

Gaming applications may require fast access to player profiles, game states, scores, and other frequently changing data.

Cosmos DB is well suited to applications requiring low latency and highly elastic workloads.

Online games में बहुत सारे players एक साथ data access करते हैं और game data frequently change होता है। इसलिए fast और scalable database की आवश्यकता होती है।

 

5. Real-Time Personalization

Cosmos DB can be used for applications that need to provide personalized content or recommendations based on user activity and preferences. Microsoft identifies real-time personalization as a suitable low-latency workload.

User की activity और preferences के आधार पर तुरंत personalized content या recommendations दिखाने के लिए Cosmos DB का उपयोग किया जा सकता है।

 

Example of Azure Cosmos DB

Suppose an online shopping application stores customer information and product data.

The application may store data such as:

  • Customer profiles
  • Product information
  • Shopping preferences
  • Orders
  • User activity

If the application becomes popular and receives users from different countries, Cosmos DB can distribute data across Azure regions and scale according to application requirements.

इस example में e-commerce application का data बढ़ने और users अलग-अलग locations से आने पर Cosmos DB global distribution और scalability की मदद से application को support कर सकता है।

 

6.4 NoSQL Concepts

NoSQL databases are an important part of modern cloud applications. They are designed to handle large amounts of data, flexible data structures, and applications that require scalability and fast access. Azure Cosmos DB is one of the Azure services that provides NoSQL database capabilities.

 

What is NoSQL?

Definition

NoSQL (Not Only SQL) is a type of database designed to store and manage data without requiring the fixed table-and-row structure commonly used by relational databases.

Explanation

Traditional relational databases generally organize data into tables, rows, and columns with a predefined schema. NoSQL databases use more flexible data models and can store data as documents, key-value pairs, graphs, or wide-column data.

NoSQL databases are particularly useful when:

  • The structure of data changes frequently.
  • Large amounts of data need to be handled.
  • Applications require high scalability.
  • Fast access to data is important.
  • Data does not naturally fit into fixed tables and relationships.

For example, a user profile in a document-based NoSQL database could contain different properties depending on the user.

NoSQL (Not Only SQL) एक प्रकार का database है जिसमें data को traditional relational database की तरह केवल fixed tables, rows और columns में store करना आवश्यक नहीं होता।

NoSQL databases flexible data structures को support करते हैं और ऐसे applications के लिए useful होते हैं जहाँ data बहुत अधिक हो, structure बदलता रहता हो या application को high scalability की आवश्यकता हो।

NoSQL vs Relational Database

Definition

A Relational Database stores structured data using tables and relationships, while a NoSQL Database uses flexible data models that can store different types of data structures.

Comparison

FeatureRelational DatabaseNoSQL Database
Data StructureTables, rows, columnsDocuments, key-value, graph, etc.
SchemaGenerally predefinedMore flexible
RelationshipsStrongly based on relationshipsUsually designed around application access patterns
ScalingCommonly vertical, with horizontal options availableCommonly designed for horizontal scaling
DataHighly structuredStructured, semi-structured, or flexible
Suitable ForTraditional business applicationsLarge-scale and flexible applications

Example

A relational database might store customer information like this:

Customer IDNameEmail
101Rahulrahul@example.com

A document-based NoSQL database could store the same customer as a document containing fields such as name, email, address, preferences, and other properties.

Relational database में data को fixed structure वाले tables में organize किया जाता है और relationships का उपयोग किया जाता है।

NoSQL database में data structure अधिक flexible होता है। इसलिए यदि application में अलग-अलग प्रकार का data store करना हो या data का structure समय के साथ बदलता रहे, तो NoSQL अधिक suitable हो सकता है।

Types of NoSQL Databases

NoSQL databases can be categorized according to how they organize and store data.

1. Document Database

A Document Database stores data as documents, commonly using JSON-like structures.

Example:

{

"name": "Rahul",

"email": "rahul@example.com",

"department": "IT"

}

Each document can contain different fields depending on the application's requirements.

Document database में data को documents के रूप में store किया जाता है। प्रत्येक document में अलग-अलग fields हो सकती हैं, इसलिए यह flexible data के लिए useful है।

2. Key-Value Database

A Key-Value Database stores data as a collection of key-value pairs.

Example:

UserID → 101

Name → Rahul

City → Jamshedpur

The key is used to identify and retrieve its corresponding value.

Key-Value database में हर data item एक key और उसके corresponding value के रूप में store होता है। यह simple और fast data retrieval के लिए useful है।

3. Wide-Column Database

A Wide-Column Database organizes data using rows and columns but allows columns to vary between rows and is designed for large-scale distributed workloads.

Wide-Column database में data columns के आधार पर organize होता है, लेकिन traditional relational tables की तुलना में इसका structure अधिक flexible हो सकता है। यह large-scale distributed applications के लिए उपयोगी है।

 

4. Graph Database

A Graph Database stores data as nodes and relationships (edges).

For example, a social networking application can represent:

User → follows → User

User → likes → Post

This makes graph databases useful when relationships between data are central to the application.

Graph database में data के साथ-साथ उनके बीच के relationships को भी store किया जाता है। इसलिए social networks, recommendation systems और relationship-based applications में इसका उपयोग किया जा सकता है।

 

Azure Cosmos DB and NoSQL

Definition

Azure Cosmos DB is a fully managed database service in Azure that provides NoSQL database capabilities and supports multiple APIs and data models.

Explanation

Cosmos DB is designed for modern applications that require flexible data models, low latency, global distribution, and elastic scalability.

With the Azure Cosmos DB for NoSQL API, applications can store data as JSON documents. These documents are stored inside containers, which are organized within a database.

A basic structure is:

Cosmos DB Account → Database → Container → Items

For example:

Database: EcommerceDB
Container: Customers

The container can contain customer items such as:

{

"id": "101",

"name": "Rahul",

"city": "Jamshedpur"

}

Another item in the same container can contain additional properties when required.

Azure Cosmos DB में NoSQL का उपयोग flexible और large-scale applications के लिए किया जाता है।

Cosmos DB for NoSQL में data को JSON documents के रूप में store किया जा सकता है। ये documents Container के अंदर रहते हैं और Container एक Database के अंदर होता है।

इसका basic structure है:

Cosmos DB Account → Database → Container → Items

इस flexible structure के कारण Cosmos DB ऐसे applications के लिए useful है जहाँ data का structure बदल सकता है और application को high scalability और fast access की आवश्यकता होती है।

 

Example

Suppose an e-commerce company wants to store customer information.

In a relational database, customer data would generally be organized into predefined tables and columns.

With a NoSQL document database, customer information can be stored as documents:

Customer 1

  • Name: Rahul
  • City: Pune
  • Orders: 5

Customer 2

  • Name: Amit
  • City: Jaisalmer
  • Orders: 3

Membership: Premium

The second customer can have an additional Membership field without requiring the same rigid structure for every document.

इस example में अलग-अलग customers के data में अलग-अलग information हो सकती है। NoSQL का flexible structure ऐसी changing requirements को आसानी से handle कर सकता है।



 

6.5 Azure Cosmos DB Database

In Azure Cosmos DB, a database is a logical container used to organize related containers and manage their resources together. It forms an important level in the Cosmos DB hierarchy between the Cosmos DB account and containers.

What is a Database in Cosmos DB?

Definition

A Database in Azure Cosmos DB is a logical organizational unit that contains one or more containers used to store application data.

Explanation

A Cosmos DB account can contain multiple databases. Each database can contain multiple containers, and containers hold the actual data items.

For example, an e-commerce application can have a database named EcommerceDB containing separate containers for customers, products, and orders.

The basic structure is:

Cosmos DB Account → Database → Container → Items

Azure Cosmos DB में Database एक logical unit है जिसका उपयोग related Containers को organize करने के लिए किया जाता है।

Database के अंदर एक या अधिक Containers हो सकते हैं और actual application data Items के रूप में Containers के अंदर store होता है।

 

Purpose of a Database

Definition

The main purpose of a Cosmos DB database is to organize related containers and provide a logical boundary for managing application data.

Explanation

A database helps organize data according to the requirements of an application.

For example, an organization may have a single Cosmos DB account containing different databases for different applications:

  • EcommerceDB
  • HRDB
  • InventoryDB

The EcommerceDB database could then contain containers such as:

  • Customers
  • Products
  • Orders

This makes the data structure easier to manage and understand.

Database का मुख्य उद्देश्य application के related data को logical तरीके से organize करना है।

उदाहरण के लिए, एक company के पास अलग-अलग applications हैं, तो प्रत्येक application के लिए अलग database बनाया जा सकता है। उस database के अंदर उस application से संबंधित अलग-अलग Containers रखे जा सकते हैं।

 

Database Structure

Azure Cosmos DB follows a hierarchical structure:

1. Cosmos DB Account : The Cosmos DB Account is the top-level Azure resource that provides access to the Cosmos DB service.

2. Database : A Database organizes related containers.

3. Container : A Container is the unit where data items are stored and managed. It also defines important settings such as the partition key.

4. Item : An Item represents an individual data record stored inside a container. In the API for NoSQL, items are commonly represented as JSON documents.

Structure Example

Cosmos DB Account: Company-CosmosDB

Database: EcommerceDB

Containers:

  • Customers
  • Products
  • Orders

Items: Individual customer, product, or order records stored inside those containers.

इस hierarchy को इस प्रकार समझ सकते हैं:

Cosmos DB Account → Database → Container → Item

Account → Cosmos DB की main Azure resource

Database → Related Containers को organize करता है 

Container → Actual data items को store करता है 

Item → Individual data record होता है 

Creating a Database

Explanation

A database can be created from the Azure Portal inside an Azure Cosmos DB account.

Basic Steps

  • Sign in to the Azure Portal.
  • Open your Azure Cosmos DB account.
  • Go to Data Explorer.
  • Select New Database.
  • Enter the Database ID, for example: EcommerceDB
  • Configure the required database settings.
  • Select Create.

After the database is created, containers can be created inside it.

Azure Portal में Cosmos DB Account के Data Explorer से नया Database बनाया जा सकता है।

Database बनाते समय एक unique Database ID दिया जाता है, जैसे EcommerceDB। Database create होने के बाद इसके अंदर Containers बनाए जा सकते हैं।

 

Example

Suppose a company is developing an online shopping application.

It creates: Cosmos DB Account: Company-CosmosDB

Database: EcommerceDB

Inside the database:

ContainerPurpose
CustomersCustomer information
ProductsProduct information
OrdersOrder information

The individual customer, product, and order records are stored as Items inside their respective containers.

इस example में EcommerceDB पूरे e-commerce application के related data को organize करता है। अलग-अलग प्रकार के data के लिए अलग Containers बनाए गए हैं और उनके actual records Items के रूप में store होते हैं।



 

6.6 Containers

A Container is one of the most important components of Azure Cosmos DB because it is the place where the actual application data is stored. It also provides the boundary for partitioning, indexing, throughput, and data management.

What is a Container?

Definition

A Container in Azure Cosmos DB is a logical unit of storage that stores and manages individual data items within a database.

Explanation

A container is similar to a collection of related data. For example, an e-commerce application may have separate containers for:

  • Customers
  • Products
  • Orders

Each container stores items related to a particular purpose.

In Azure Cosmos DB for NoSQL, the items stored in a container are commonly represented as JSON documents.

Container Azure Cosmos DB में वह logical unit है जहाँ application का actual data/items store होते हैं।

एक Database के अंदर अलग-अलग requirements के लिए multiple Containers बनाए जा सकते हैं।

उदाहरण के लिए, e-commerce application में:

Customers → Customer data

Products → Product data

Orders → Order data

इस तरह अलग-अलग प्रकार के data को अलग Containers में organize किया जा सकता है।

 

Container in Azure Cosmos DB

Definition

A Cosmos DB Container is a scalable unit that stores data items and provides important configuration such as partitioning, indexing, and throughput.

Explanation

When creating a container, you specify important settings such as:

  • Container ID – Name of the container.
  • Partition Key – Property used to logically distribute data.
  • Throughput – Determines the amount of database resources available for the container.
  • Indexing – Helps efficiently query data stored in the container.

For example:

  • Database: EcommerceDB
  • Container: Customers

The container may contain items such as:

{

"id": "101",

"name": "Rahul",

"city": "Jamshedpur"

}

Another item can contain different properties because Cosmos DB for NoSQL supports flexible JSON data.

Container केवल files रखने की जगह नहीं है। यह data को store करने के साथ-साथ partitioning, indexing और throughput जैसी important settings को भी manage करता है।

Container create करते समय Partition Key का selection विशेष रूप से important होता है क्योंकि यह data को अलग-अलग logical partitions में distribute करने में मदद करता है।

 

Database vs Container

Definition

A Database organizes related containers, while a Container stores and manages the actual data items.

FeatureDatabaseContainer
PurposeOrganizes related containersStores and manages data items
ContainsContainersItems
ExampleEcommerceDBCustomers
Data StorageDoes not directly contain individual itemsContains actual items
PartitioningHigher-level organizationPartitioning is configured at container level

Example

Suppose an organization creates:

Cosmos DB Account
→ EcommerceDB (Database)
→ Customers (Container)
→ Customer Items

The database organizes the containers, while the container stores the actual customer records.

इसे simple hierarchy से समझ सकते हैं:

Cosmos DB Account → Database → Container → Items

Database = Containers को organize करता है। 

Container = Actual data/items को store करता है। 

इसलिए Database को एक organizational level और Container को data storage and management level के रूप में समझ सकते हैं।

 

Creating a Container

Explanation

A container can be created inside an existing Cosmos DB database through the Azure Portal.

Basic Steps

Sign in to the Azure Portal.

  1. Open your Azure Cosmos DB account.
  2. Go to Data Explorer.
  3. Select the required Database.
  4. Select New Container.
  5. Enter the Container ID, for example:
    Customers
  6. Select the appropriate Partition Key.
  7. Configure the required throughput and other settings.
  8. Select OK/Create.

The container is then created inside the selected database.

Azure Portal में Data Explorer के माध्यम से existing Database के अंदर Container बनाया जा सकता है।

Container बनाते समय उसका Container ID और Partition Key configure करना आवश्यक होता है। इसके बाद Container के अंदर actual data Items के रूप में add किए जा सकते हैं।

 

Example

Suppose an online shopping company has:

  • Cosmos DB Account: Company-CosmosDB
  • Database: EcommerceDB

It creates three Containers:

ContainerData Stored
CustomersCustomer information
ProductsProduct information
OrdersOrder information

The Customers container may contain individual customer items, while the Products container contains product items.

यहाँ EcommerceDB पूरे application के data को organize करता है, जबकि Customers, Products और Orders अलग-अलग Containers हैं जिनमें संबंधित actual data store किया जाता है।

6.7 Partition Keys

A Partition Key is an important concept in Azure Cosmos DB because it determines how data is logically distributed within a container. Choosing an appropriate partition key helps Cosmos DB achieve scalability, performance, and efficient data distribution.

What is a Partition Key?

Definition

A Partition Key is a property in each item that Cosmos DB uses to logically divide and distribute data within a container.

Explanation

When a container contains a large amount of data, storing everything as one large dataset would not provide efficient scalability. Cosmos DB uses partitioning to divide the data into smaller logical groups called logical partitions.

When creating a container, you specify a partition key path, such as: /userId

If an item contains:

{

"id": "101",

"userId": "U001",

"name": "Rahul"

}

Cosmos DB uses the value of userId to determine the logical partition to which the item belongs.

Partition Key एक ऐसी property होती है जिसका उपयोग Azure Cosmos DB किसी Container के data को logically अलग-अलग partitions में distribute करने के लिए करता है।

जब Container में बहुत अधिक data होता है, तो उसे छोटे logical groups में distribute करना scalability और performance के लिए उपयोगी होता है।

 

Why Partition Keys are Used

Definition

Partition Keys are used to distribute data and workload across partitions, allowing Cosmos DB containers to scale and handle large amounts of data and requests.

Explanation

A good partition key helps distribute both storage and request traffic more evenly.

For example, suppose an application stores millions of customer records. If /customerId is selected as the partition key and customer IDs are well distributed, the data and requests can be spread across different logical partitions.

Partitioning helps Cosmos DB support:

  • Large amounts of data
  • High request volumes
  • Horizontal scalability
  • Efficient data access

Partition Key का मुख्य उद्देश्य data और requests को अलग-अलग partitions में efficiently distribute करना है।

यदि partition key अच्छी तरह चुनी गई है, तो किसी एक partition पर बहुत अधिक load नहीं आता और workload अधिक evenly distribute हो सकता है।

 

Choosing a Partition Key

Definition

Choosing a partition key means selecting a property that provides good data distribution and supports the application's common query patterns.

Important Considerations

1. High Cardinality

Choose a property that can have many different values.

For example:

  • Good: customerId
    Potentially Poor: country

If millions of users are divided only into a few countries, some partitions may receive much more data than others.

ऐसी property चुनना बेहतर होता है जिसके बहुत सारे अलग-अलग values हों, ताकि data अच्छी तरह distribute हो सके।

 

2. Even Data Distribution

The selected partition key should distribute data and requests relatively evenly.

For example, if one value receives most of the application's requests, it can create a hot partition.

Partition Key ऐसी होनी चाहिए जिससे data और traffic एक ही partition पर बहुत अधिक concentrated न हो।

 

3. Query Requirements

Consider how the application commonly queries the data.

For example, if an application frequently retrieves all information belonging to a particular customer, customerId can be a useful partition key.

Partition Key चुनते समय यह भी देखना चाहिए कि application में data को सामान्यतः कैसे query किया जाता है

 

4. Avoid Frequently Changing Properties

A partition key value is part of an item's identity within the container's partitioning scheme. Therefore, a property that frequently changes is generally not a good choice.

ऐसी property चुनने से बचना चाहिए जिसका value बार-बार बदलता रहता हो, क्योंकि partitioning के लिए stable property अधिक suitable होती है।

 

Partition Key Example

Suppose an e-commerce application has a Customers container.

Container

Database: EcommerceDB
Container: Customers

Suppose the partition key is:

/customerId

The container contains:

idcustomerIdname
101C001Rahul
102C002Amit
103C003Priya
104C004Neha

Here, Cosmos DB uses the customerId value to determine the logical partition for each item.

For example:

Customer Item

customerId = C001

Partitioning based on /customerId

Another item with customerId = C002 is associated with its corresponding logical partition.

इस example में /customerId को Partition Key बनाया गया है।

हर customer के पास अलग customerId है। Cosmos DB इस value का उपयोग करके items को logical partitions में organize करता है।

इससे बड़े customer dataset को efficiently manage और scale करना आसान होता है।
 

 

6.8 Practical Labs

Practical 1: Create Azure File Share

Objective

Create an Azure Storage Account and create a File Share inside it.

Steps

  1. Sign in to the Azure Portal.
  2. Search for Storage Accounts.
  3. Select Create.
  4. Select the required Subscription and Resource Group.
  5. Enter a unique Storage Account Name.
  6. Select the required Region.
  7. Keep the required storage configuration settings.
  8. Select Review + Create.
  9. Select Create.
  10. Open the newly created Storage Account.
  11. Under Data storage, select File shares.
  12. Select + File share.
  13. Enter a File Share Name.
  14. Select Create.

Open the File Share and verify that it has been created successfully.

इस practical में पहले Storage Account बनाया जाएगा और उसके अंदर File Share create किया जाएगा। File Share का उपयोग files और folders को shared storage के रूप में रखने के लिए किया जाता है।

 

Practical 2: Create Cosmos DB NoSQL Account

Objective

Create an Azure Cosmos DB account using the NoSQL API and configure its basic settings.

Steps

  1. Sign in to the Azure Portal.
  2. Search for Azure Cosmos DB.
  3. Select Create.
  4. Select Azure Cosmos DB for NoSQL.
  5. Select the required Subscription.
  6. Select or create a Resource Group.
  7. Enter a unique Account Name.
  8. Select the required Region.
  9. Review the basic configuration.
  10. Configure the required capacity and availability settings.
  11. Select Review + Create.
  12. Select Create.

Wait for the deployment to complete.

Open the Cosmos DB account and verify the configuration.

इस practical में Cosmos DB for NoSQL account बनाया जाएगा। Account create करते समय Subscription, Resource Group, Account Name और Region जैसी basic settings configure की जाएंगी।

 

Practical 3: Create Database and Container

Objective

Create a Database and Container inside the Cosmos DB account and configure a Partition Key.

Steps

  1. Open the Azure Cosmos DB account.
  2. Select Data Explorer.
  3. Select New Database.
  4. Enter the Database ID, for example:
    EcommerceDB
  5. Create the Database.
  6. Select New Container.
  7. Enter the Container ID, for example:
    Customers
  8. Select the Partition Key path, for example:
    /customerId
  9. Configure the required throughput settings.
  10. Select Create.

Verify that the Database and Container appear in Data Explorer.

इस practical में पहले Cosmos DB account के अंदर Database बनाया जाएगा। उसके बाद Database के अंदर Container बनाया जाएगा।

Container create करते समय Partition Key configure की जाएगी, जो data को logical partitions में distribute करने में मदद करती है।

 

Practical 4: Insert Data

Objective

Insert sample data into the Cosmos DB Container and verify the stored data.

Steps

  • Open the Cosmos DB account.
  • Open Data Explorer.
  • Expand the required Database.
  • Select the required Container.
  • Select Items.
  • Select New Item.

Enter a sample JSON document.

Example:

{

"id": "101",

"customerId": "C001",

"name": "Rahul",

"city": "Jamshedpur"

}

Select Save.

Open the Items section.

Select the newly created item.

Verify the stored data and its properties.

इस practical में Container के अंदर sample Item insert किया जाएगा। Data को JSON format में enter करके save किया जाएगा। इसके बाद Items section से verify किया जाएगा कि data successfully store हुआ है।