{"id":1950,"date":"2018-11-27T00:00:00","date_gmt":"2018-11-27T00:00:00","guid":{"rendered":"https:\/\/azure.microsoft.com\/blog\/azure-cosmos-db-and-multi-tenant-systems"},"modified":"2023-05-11T15:35:47","modified_gmt":"2023-05-11T22:35:47","slug":"azure-cosmos-db-and-multi-tenant-systems","status":"publish","type":"post","link":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/","title":{"rendered":"Azure Cosmos DB and multi-tenant systems"},"content":{"rendered":"<p>In this blog post, we will discuss how to build a multi-tenant system on Azure Cosmos DB. Azure Cosmos DB itself is a multi-tenant PaaS offering on Microsoft Azure. Building a multi-tenant system on another multi-tenant system can be challenging, but Azure provides us all the tools to make our task easy. An example of a multi-tenant system would be a company providing background check services that any other company can use in their HR system. For the purposes of this blog post we are going to use this example and continue from the point of view of company providing background checks as a service. We will refer to this company as \u201cpublisher.\u201d<\/p>\n<p>Let\u2019s begin to discuss how you can build a multi-tenant system that will store sensitive user data. Data isolation and security is the most important aspect of any system. <strong>We must design the system so that each tenant\u2019s data is isolated from one another<\/strong>. The data stored in any given tenant should be divided into compartments so one tenant breach cannot flow into another tenant. This would be similar to compartmentalizing the hull of a ship to reduce <a href=\"https:\/\/en.wikipedia.org\/wiki\/Ship_floodability\" target=\"_blank\" rel=\"noopener\">floodability<\/a>.<\/p>\n<p>To increase the isolation and protection of customer data in a multi-tenant system, we should build the system with only one approved service that can have just in time (JIT) access to tenant data. We need to set up a different system principal for each customer\u2019s data partition so that the scope of access for any principal is segmented by customer. We don\u2019t want a service to have access to all tenant data, that is a big security risk. What we want is the service to get the access permission for one tenant JIT. The benefit of this approach is tenants can rotate their certificates and keys anytime.<\/p>\n<p>Every tenant can manage their data using the publisher&#8217;s front-end service (FES), but they cannot directly manipulate their own data in Azure Cosmos DB collections. This isolation will remove the need for every tenant to have access to master and read-only keys. All the data access will happen through a service and no one will access Azure Cosmos DB unless directly on the portal or through code. The publisher application, which manages the customer data, is hosted in a different Azure Active Directory tenant and subscription, which is separate from that of the customer\u2019s tenant and data.<\/p>\n<p>However, the tenant will own all the collections and data without having direct access to the data. This simplifies the billing for all data storage and throughput that the tenant is directly billed, but is a tricky requirement. Let\u2019s see how you can manage this requirement.<\/p>\n<p>The main actors of this solution are <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/managed-applications\/overview\" target=\"_blank\" rel=\"noopener\">Azure Managed Applications<\/a>, <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/active-directory\/develop\/service-to-service\" target=\"_blank\" rel=\"noopener\">Daemon Application<\/a>, <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cosmos-db\/introduction\" target=\"_blank\" rel=\"noopener\">Azure Cosmos DB<\/a>, <a href=\"https:\/\/azure.microsoft.com\/en-us\/services\/key-vault\/\" target=\"_blank\" rel=\"noopener\">Azure Key Vault<\/a> and <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/active-directory\/fundamentals\/active-directory-whatis\" target=\"_blank\" rel=\"noopener\">Azure Active Directory<\/a> (AAD). The following paragraphs will help us understand each of the mentioned solutions.<\/p>\n<p>An Azure Managed Application is like a service catalog in the marketplace, but with one key difference. In a managed application, the resources are provisioned in a resource group that is managed by the publisher of the app. The resource group is present in the consumer&#8217;s subscription, but an identity in the publisher&#8217;s tenant has access to the resource group in the customer subscription. As the publisher, you specify the <a href=\"https:\/\/azure.microsoft.com\/en-us\/pricing\/details\/managed-applications\/\" target=\"_blank\" rel=\"noopener\">cost of ongoing support for the solution<\/a>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"Customer subscription flow chart\" height=\"200\" src=\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/11\/e4182aa3-487d-4584-b05e-c601df406d39.webp\" title=\"Customer subscription flow chart\" width=\"558\"><\/p>\n<p>Managed applications reduce barriers to consumers using your solutions. They do not need expertise in cloud infrastructure to use your solution. Consumers have limited access to the critical resources. They don&#8217;t need to worry about making a mistake when managing it. Managed applications enable customers to adopt your solution without needing expertise in the underlying Azure infrastructure.<\/p>\n<p>Managed applications enable you to establish an ongoing relationship with your consumers. You define the terms for managing the application, and all charges are handled through Azure billing.<\/p>\n<p>Although customers deploy these managed applications in their subscriptions, they do not have to maintain, update, or service them. You can ensure that all customers are using approved versions. Customers do not have to develop application specific domain knowledge to manage these applications. They automatically acquire application updates without the need to worry about troubleshooting and diagnosing issues with the applications. The advantages of an Azure Managed Application is billing, separation of data between different tenants, easy maintenance, among other benefits. For more details, read more about <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/managed-applications\/overview\" target=\"_blank\" rel=\"noopener\">Azure Managed Applications<\/a>.<\/p>\n<p>After deploying a tenant managed application, create a daemon application. Follow the instructions on <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/active-directory\/develop\/howto-authenticate-service-principal-powershell\" target=\"_blank\" rel=\"noopener\">how to create an AAD application and service principal<\/a> that can access resources. This daemon application has its own identity and access to tenant subscription. This application is the bridge between the customer tenant application and the service provider (publisher).<\/p>\n<p>It is important to understand a few things. First, user interaction is not possible with a daemon application, which requires the application to have its own identity. An example of a daemon application is a batch job, or an operating system service running in the background. This type of application requests an access token by using its application identity and presenting its application ID, credentials (password or certificate), and application ID URI to AAD. After a successful authentication, the daemon receives an access token which represents the identity of the application from AAD and is then used to call the web API.<\/p>\n<p>The magic of Azure Managed Applications is that the publisher can access the customer subscription resources it managed as if these resources are located within a subscription in the publisher\u2019s AAD tenant. The customer tenant subscription resources are visible to the customer in their own Azure subscription, but are not accessible due to an Azure Resource Lock. Only the publisher has full access to the managed application resources in the customer\u2019s subscription.<\/p>\n<p>After creating the daemon application, you need to register it in the identity and access (IAM) of Azure Cosmos DB instance, which is deployed as a managed resource component of the customer tenant subscription.<\/p>\n<p>The last piece you will develop is the front-end service (FES). This the service used to manage the components in the customer tenant. This service cannot directly access Azure Cosmos DB until it goes through the orchestration of taking the daemon application identity. The following illustrates a step-by-step walkthrough for the FES interaction with the customer\u2019s subscription resources.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"FES interaction with the customer subscription resources flow chart\" height=\"375\" src=\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/11\/2c3fa919-d443-45c3-90a1-da33a13f0914.webp\" title=\"FES interaction with the customer subscription resources flow chart\" width=\"558\"><\/p>\n<p>FES takes over the daemon application identity at the run time. FES also has its own managed identity (MSI) which is registered in Key Vault for access. At the run time, the FES connects to the Key Vault using the Azure MSI and obtains the certificate credential, which in turn uses a credential to obtain a token from AAD representing the daemon application (Step 1).<\/p>\n<p>Once the FES gets the certificates, it assumes the identity of daemon service by using the client ID and secret certificate. Then it will call AAD to get the access token for the Managed Application (Step 2). This FES uses Azure Active Directory Authorization DLL (AAD DLL). See the FES code snippet below, which helps FES to get the token from AAD.<\/p>\n<pre>\r\nusing Microsoft.Azure.KeyVault;\r\nusing Microsoft.Azure.Services.AppAuthentication;\r\nusing Microsoft.IdentityModel.Clients.ActiveDirectory;\r\n\r\nstring secretIdentifier = \" key vault secretIdentifier for daemon app goes here \";\r\nvar tokenCache = TokenCache.DefaultShared;\r\nstring pubTenantId = \" publisher\u2019s Azure AD directory id here \";\r\n\r\n\/\/\/\/ get app key from Key Vault (\u2026 let me know if you need a sample for reading a certificate\/private key instead of a secret\r\nvar azureServiceTokenProvider = new AzureServiceTokenProvider();\r\n\r\nvar keyVaultClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback));\r\nstring secret = keyVaultClient.GetSecretAsync(appKey)\r\n.GetAwaiter()\r\n.GetResult();\r\n\r\n\/\/\/\/ now get a token representing the Daemon app, using the secret credential of the Daemon Azure AD application.  Resource is the appropriate Azure resource Uri.\r\nstring daemonAppId = \"daemon Azure AD application Id\";\r\nstring authString = $\"https:\/\/login.microsoftonline.com\/{pubTenantId}\";\r\nstring daemonAppResourceUri = \"https:\/\/management.core.windows.net\/\";\r\nvar clientCredential = new ClientCredential(daemonAppId, secret.Value);\r\nvar authenticationContext = new AuthenticationContext(authString, false, tokenCache);\r\n\r\nvar authnResult = authenticationContext.AcquireTokenAsync(resourceUri, clientCredential)\r\n.GetAwaiter()\r\n.GetResult();\r\n\r\nstring daemonToken = authnResult.AccessToken;\r\n\r\n\/\/\/\/ alternately, to use a certificate you would substitute the above variables:\r\n\/\/\/\/     var clientCredential = new ClientAssertionCertificate(clientId, certificate);<\/pre>\n<p>Once the access token is obtained by FES, it calls into Azure Cosmos DB to get the master key (Step 3 and 4). This is accomplished by using the access token of the daemon application. For this FES we pass the AAD token in header.<\/p>\n<pre>\r\nusing Microsoft.Azure.Management.CosmosDB.Fluent;\r\nusing Microsoft.Azure.Management.Fluent;\r\nusing Microsoft.Azure.Management.ResourceManager.Fluent;\r\nusing Microsoft.Azure.Management.ResourceManager.Fluent.Core;\r\n\r\nstring subscriptionId = \" subscribing customer\u2019s subscription id \";\r\nstring resourceGroupName = \" subscribing customer\u2019s resource group name \";\r\nstring databaseAccountName = \" subscribing customer\u2019s Cosmos DB account name \";\r\n\r\nvar credential = new AzureCredentials(new TokenCredentials(daemonToken), pubTenantId, AzureEnvironment.AzureGlobalCloud);\r\n\r\nvar azure = Azure.Configure()\r\n.WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)\r\n.Authenticate(credential)\r\n.WithSubscription(subscriptionId);\r\n\r\nvar cosmosDbAccounts = azure.CosmosDBAccounts;\r\nvar readWritekeys = cosmosDbAccounts.ListKeysAsync(resourceGroupName, databaseAccountName)\r\n.GetAwaiter()\r\n.GetResult();<\/pre>\n<p>Once it has the master key, it starts accessing the Cosmos DB (Step 5).<\/p>\n<pre>\r\nusing Microsoft.Azure.Documents;\r\nusing Microsoft.Azure.Documents.Client;\r\n\r\nstring cosmosDBendpointUri = $\"{databaseAccountName}.documents.azure.com:443\/\";\r\n\r\nstring masterKey = readWritekeys.PrimaryMasterKey; \/\/\/\/ pick the one you need\r\n\r\nvar connectionPolicy = new ConnectionPolicy { ConnectionMode = ConnectionMode.Direct, ConnectionProtocol = Protocol.Tcp };\r\n\r\nvar documentClient = new DocumentClient(new Uri(cosmosDBendpointUri), masterKey, connectionPolicy);\r\n\r\nclient.OpenAsync()\r\n.GetAwaiter()\r\n.GetResult();<\/pre>\n<p>You may wonder why the daemon application identity, rather than an <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/active-directory\/managed-identities-azure-resources\/overview\" target=\"_blank\" rel=\"noopener\">Azure MSI<\/a> representing the FES, is used to retrieve the Azure Cosmos DB keys. The answer is security isolation, JIT access, getting the daemon application secret from Key Vault, and accessing AAD to get it\u2019s token all help support security isolation. This orchestration makes sure that FES does not have access to all the tenants\u2019 keys. It can get access to keys JIT only by using the daemon identity.<\/p>\n<p>This system has the following advantages:<\/p>\n<ul>\n<li>No access key is kept with the publisher, in code, or in any configuration files. This method provides the security needed for every tenant.<\/li>\n<li>One publisher access token cannot access all the tenants.<\/li>\n<li>Each subscribing customer is provisioned with its own daemon application identity for access to that customer\u2019s resources.<\/li>\n<li>Only at the run time can FES get the access token by using the daemon application secrets.<\/li>\n<\/ul>\n<p>Azure Cosmos DB brings many of its advantages to this solution, such as:<\/p>\n<ul>\n<li>The publisher does not know how much throughput and space is required at the time of onboarding a new tenant.<\/li>\n<li>Azure Cosmos DB\u2019s elastic nature for storage and throughput keeps this solution very flexible.<\/li>\n<li>The Azure Managed Applications template defined by the publisher comes with a minimum default Azure Cosmos DB whose request units can be expanded as needed.<\/li>\n<li>JIT access through the use of daemon applications and Key Vault.<\/li>\n<\/ul>\n<p>I hope this article provided you with enough pointers to help you get started on your journey to build a multi-tenant system over Azure Cosmos DB.<\/p>\n<p><em>Special thanks to Terry Carter, Nikisha Reyes-Grange, and Sneha Gunda for their contribution to this blog post.<\/em><\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog post we will discuss how to build a multi-tenant system on Azure Cosmos DB. Azure Cosmos DB itself is a multi-tenant PaaS offering on Azure.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"ms_queue_id":[],"ep_exclude_from_search":false,"_classifai_error":"","_classifai_text_to_speech_error":"","_alt_title":"","footnotes":"","msx_community_cta_settings":[]},"categories":[1473,1485],"tags":[],"audience":[3057,3055,3053,3056],"content-type":[1481],"product":[1538],"tech-community":[],"topic":[],"coauthors":[97],"class_list":["post-1950","post","type-post","status-publish","format-standard","hentry","category-databases","category-internet-of-things","audience-data-professionals","audience-developers","audience-it-decision-makers","audience-it-implementors","content-type-thought-leadership","product-azure-cosmos-db"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Azure Cosmos DB and multi-tenant systems | Microsoft Azure Blog<\/title>\n<meta name=\"description\" content=\"In this blog post we will discuss how to build a multi-tenant system on Azure Cosmos DB. Azure Cosmos DB itself is a multi-tenant PaaS offering on Azure.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Azure Cosmos DB and multi-tenant systems | Microsoft Azure Blog\" \/>\n<meta property=\"og:description\" content=\"In this blog post we will discuss how to build a multi-tenant system on Azure Cosmos DB. Azure Cosmos DB itself is a multi-tenant PaaS offering on Azure.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/\" \/>\n<meta property=\"og:site_name\" content=\"Microsoft Azure Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/microsoftazure\" \/>\n<meta property=\"article:published_time\" content=\"2018-11-27T00:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-05-11T22:35:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/11\/e4182aa3-487d-4584-b05e-c601df406d39.webp\" \/>\n<meta name=\"author\" content=\"Microsoft Azure\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@azure\" \/>\n<meta name=\"twitter:site\" content=\"@azure\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Microsoft Azure\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/\"},\"author\":[{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/author\/microsoft-azure\/\",\"@type\":\"Person\",\"@name\":\"Microsoft Azure\"}],\"headline\":\"Azure Cosmos DB and multi-tenant systems\",\"datePublished\":\"2018-11-27T00:00:00+00:00\",\"dateModified\":\"2023-05-11T22:35:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/\"},\"wordCount\":1532,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/11\/e4182aa3-487d-4584-b05e-c601df406d39.webp\",\"articleSection\":[\"Databases\",\"Internet of things\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/\",\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/\",\"name\":\"Azure Cosmos DB and multi-tenant systems | Microsoft Azure Blog\",\"isPartOf\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/11\/e4182aa3-487d-4584-b05e-c601df406d39.webp\",\"datePublished\":\"2018-11-27T00:00:00+00:00\",\"dateModified\":\"2023-05-11T22:35:47+00:00\",\"description\":\"In this blog post we will discuss how to build a multi-tenant system on Azure Cosmos DB. Azure Cosmos DB itself is a multi-tenant PaaS offering on Azure.\",\"breadcrumb\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/#primaryimage\",\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/11\/e4182aa3-487d-4584-b05e-c601df406d39.webp\",\"contentUrl\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/11\/e4182aa3-487d-4584-b05e-c601df406d39.webp\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog home\",\"item\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Databases\",\"item\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/category\/databases\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Azure Cosmos DB and multi-tenant systems\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#website\",\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/\",\"name\":\"Microsoft Azure Blog\",\"description\":\"Get the latest Azure news, updates, and announcements from the Azure blog. From product updates to hot topics, hear from the Azure experts.\",\"publisher\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization\",\"name\":\"Microsoft Azure Blog\",\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2024\/06\/microsoft_logo.webp\",\"contentUrl\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2024\/06\/microsoft_logo.webp\",\"width\":512,\"height\":512,\"caption\":\"Microsoft Azure Blog\"},\"image\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/microsoftazure\",\"https:\/\/x.com\/azure\",\"https:\/\/www.instagram.com\/microsoftdeveloper\/\",\"https:\/\/www.linkedin.com\/company\/16188386\",\"https:\/\/www.youtube.com\/user\/windowsazure\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/person\/c702e5edd662b328b49b7e1180cab117\",\"name\":\"shakir\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g7664e653ea371ce16eaf75e9fa8952c4\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g\",\"caption\":\"shakir\"},\"sameAs\":[\"https:\/\/azure.microsoft.com\"],\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/author\/shakir\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Azure Cosmos DB and multi-tenant systems | Microsoft Azure Blog","description":"In this blog post we will discuss how to build a multi-tenant system on Azure Cosmos DB. Azure Cosmos DB itself is a multi-tenant PaaS offering on Azure.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/","og_locale":"en_US","og_type":"article","og_title":"Azure Cosmos DB and multi-tenant systems | Microsoft Azure Blog","og_description":"In this blog post we will discuss how to build a multi-tenant system on Azure Cosmos DB. Azure Cosmos DB itself is a multi-tenant PaaS offering on Azure.","og_url":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/","og_site_name":"Microsoft Azure Blog","article_publisher":"https:\/\/www.facebook.com\/microsoftazure","article_published_time":"2018-11-27T00:00:00+00:00","article_modified_time":"2023-05-11T22:35:47+00:00","og_image":[{"url":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/11\/e4182aa3-487d-4584-b05e-c601df406d39.webp","type":"","width":"","height":""}],"author":"Microsoft Azure","twitter_card":"summary_large_image","twitter_creator":"@azure","twitter_site":"@azure","twitter_misc":{"Written by":"Microsoft Azure","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/#article","isPartOf":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/"},"author":[{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/author\/microsoft-azure\/","@type":"Person","@name":"Microsoft Azure"}],"headline":"Azure Cosmos DB and multi-tenant systems","datePublished":"2018-11-27T00:00:00+00:00","dateModified":"2023-05-11T22:35:47+00:00","mainEntityOfPage":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/"},"wordCount":1532,"commentCount":0,"publisher":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization"},"image":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/#primaryimage"},"thumbnailUrl":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/11\/e4182aa3-487d-4584-b05e-c601df406d39.webp","articleSection":["Databases","Internet of things"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/","url":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/","name":"Azure Cosmos DB and multi-tenant systems | Microsoft Azure Blog","isPartOf":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/#primaryimage"},"image":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/#primaryimage"},"thumbnailUrl":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/11\/e4182aa3-487d-4584-b05e-c601df406d39.webp","datePublished":"2018-11-27T00:00:00+00:00","dateModified":"2023-05-11T22:35:47+00:00","description":"In this blog post we will discuss how to build a multi-tenant system on Azure Cosmos DB. Azure Cosmos DB itself is a multi-tenant PaaS offering on Azure.","breadcrumb":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/#primaryimage","url":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/11\/e4182aa3-487d-4584-b05e-c601df406d39.webp","contentUrl":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/11\/e4182aa3-487d-4584-b05e-c601df406d39.webp"},{"@type":"BreadcrumbList","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-and-multi-tenant-systems\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog home","item":"https:\/\/azure.microsoft.com\/en-us\/blog\/"},{"@type":"ListItem","position":2,"name":"Databases","item":"https:\/\/azure.microsoft.com\/en-us\/blog\/category\/databases\/"},{"@type":"ListItem","position":3,"name":"Azure Cosmos DB and multi-tenant systems"}]},{"@type":"WebSite","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#website","url":"https:\/\/azure.microsoft.com\/en-us\/blog\/","name":"Microsoft Azure Blog","description":"Get the latest Azure news, updates, and announcements from the Azure blog. From product updates to hot topics, hear from the Azure experts.","publisher":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/azure.microsoft.com\/en-us\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization","name":"Microsoft Azure Blog","url":"https:\/\/azure.microsoft.com\/en-us\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2024\/06\/microsoft_logo.webp","contentUrl":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2024\/06\/microsoft_logo.webp","width":512,"height":512,"caption":"Microsoft Azure Blog"},"image":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/microsoftazure","https:\/\/x.com\/azure","https:\/\/www.instagram.com\/microsoftdeveloper\/","https:\/\/www.linkedin.com\/company\/16188386","https:\/\/www.youtube.com\/user\/windowsazure"]},{"@type":"Person","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/person\/c702e5edd662b328b49b7e1180cab117","name":"shakir","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g7664e653ea371ce16eaf75e9fa8952c4","url":"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g","caption":"shakir"},"sameAs":["https:\/\/azure.microsoft.com"],"url":"https:\/\/azure.microsoft.com\/en-us\/blog\/author\/shakir\/"}]}},"msxcm_display_generated_audio":false,"msxcm_animated_featured_image":null,"distributor_meta":false,"distributor_terms":false,"distributor_media":false,"distributor_original_site_name":"Microsoft Azure Blog","distributor_original_site_url":"https:\/\/azure.microsoft.com\/en-us\/blog","push-errors":false,"_links":{"self":[{"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/posts\/1950","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/comments?post=1950"}],"version-history":[{"count":0,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/posts\/1950\/revisions"}],"wp:attachment":[{"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/media?parent=1950"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/categories?post=1950"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/tags?post=1950"},{"taxonomy":"audience","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/audience?post=1950"},{"taxonomy":"content-type","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/content-type?post=1950"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/product?post=1950"},{"taxonomy":"tech-community","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/tech-community?post=1950"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/topic?post=1950"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/coauthors?post=1950"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}