Designing an Azure multi-tenant architecture requires careful consideration of several factors to ensure scalability, security, and manageability.
To accommodate multiple tenants, you'll need to implement a robust identity and access management system, such as Azure Active Directory (Azure AD), which supports multiple directories and tenants out of the box.
This allows each tenant to have its own isolated environment, with access to only the resources and services they need, reducing the risk of data breaches and unauthorized access.
Implementing a centralized logging and monitoring system, such as Azure Monitor, is also crucial to track and analyze activity across all tenants, enabling you to identify potential issues before they become major problems.
Azure Multi-Tenant Architecture
Azure Multi-Tenant Architecture is a design approach that allows multiple tenants to share the same Azure resources, while maintaining isolation and security for each tenant. This approach is particularly useful for Software as a Service (SaaS) applications.
There are several ways to implement Azure multi-tenant architecture, including sharing an Azure OpenAI instance among multiple tenants. However, this approach provides the least data isolation and performance isolation, and should be avoided when using fine-tuned models.
To achieve better isolation, consider deploying multiple shared Azure OpenAI instances, or having tenants create their own Azure OpenAI instance in their own Azure subscription and grant your application access to it. This approach provides more control over data isolation and security, but requires more complexity in implementation.
Here are some key considerations for Azure multi-tenant architecture:
- Cost efficiency: Sharing hosting infrastructure can reduce overall costs per tenant.
- Separation of configuration: Each tenant's app can have its own domain name, TLS certificate, access restrictions, and token authorization policies.
- Separation of upgrades: Each tenant's application binaries can be upgraded independently of other apps on the same plan.
Ultimately, the choice of Azure multi-tenant architecture will depend on the specific needs and requirements of your SaaS application. By carefully considering the trade-offs between complexity, cost, and security, you can design an architecture that meets the needs of your tenants while minimizing operational overhead.
Tenant-Provided OpenAI Resource
In some situations, your tenants might create the Azure OpenAI instance in their own Azure subscriptions and grant your application access to it.
This approach is suitable when tenants have specific quotas and permissions from Microsoft, such as access to different models, specific content filtering policies, or the use of provisioned throughput.
Tenants might also require a fine-tuned model they need to use from your solution, or they might need a component in their environment to process and send data through their customer-managed Azure OpenAI instance for processing.
To access an Azure OpenAI instance in your tenant's subscription, the tenant must provide your application with access, and your application must authenticate through their Microsoft Entra instance.
Here are the steps to follow:
- The tenant registers the multitenant Microsoft Entra application in their own Microsoft Entra tenant.
- The tenant grants the multitenant Microsoft Entra application the appropriate level of access to their Azure OpenAI resource.
- The tenant provides the resource ID of the Azure OpenAI resource that they create.
- Your application code can use a service principal that's associated with the multitenant Microsoft Entra application in your own Microsoft Entra instance to access the tenant's Azure OpenAI instance.
Alternatively, you might ask each tenant to create a service principal for your service to use, and to provide you with its credentials. However, this approach requires securely storing and managing credentials for each tenant, which is a potential security liability.
Custom Domain Names
Custom Domain Names can be a challenge to manage, especially when you have a large number of tenants.
Azure App Service enables you to use wildcard DNS to easily scale your solution to a large number of tenants. This eliminates the need for manual reconfiguration for each new tenant.
Tenant-specific custom domain names can become cumbersome to manage, requiring individual TLS certificates for each domain. App Service provides managed TLS certificates, which reduces the work required when working with custom domains.
However, there are limits to consider, such as how many custom domains can be applied to a single app.
Plans
In Azure multi-tenant architecture, plans play a crucial role in ensuring tenant isolation and performance.
The strongest level of isolation is achieved by deploying a dedicated plan for each tenant. This approach provides full use of server resources and avoids the Noisy Neighbor problem, but comes with a higher cost.
To scale your solution, you can deploy separate apps for each tenant on a shared plan. This offers cost efficiency and separation of configuration, but may be subject to the Noisy Neighbor problem.
You can also consider deploying a shared application on a single plan, which tends to be the most cost-efficient option with the least operational overhead.
Here are the key differences between the three approaches:
It's essential to be aware of the App Service quotas and limits, such as the maximum number of custom domains that can be added to a single app and the maximum number of instances of a plan that can be provisioned.
Multitenant Guidance
Sharing a model deployment among tenants simplifies your operational burden because you have fewer deployments to manage, and model versions to track.
You can also choose to share your plan with multiple tenants but deploy separate apps for each tenant, providing logical isolation between each tenant and several advantages, including cost efficiency, separation of configuration, and separation of upgrades.
A per-tenant database approach can provide several significant advantages, including enhanced data isolation and security, more granular performance tuning, and easier data backup and recovery.
To test multi-tenant operations in Azure, you can use Postman to publish your changes and test creating a new tenant with an isolated database in your Azure SQL Elastic Pool.
You can deploy multiple shared Azure OpenAI instances, for example, if you follow the Deployment Stamps pattern, deploy a shared Azure OpenAI instance in each stamp, to avoid cross-region traffic latency, support data residency requirements, and enable the use of regional Azure OpenAI within other services that require same-region deployments.
The following architectures provide examples of multitenant architectures on Azure:
OpenAI Services
Microsoft Azure provides a robust set of services to build, deploy, and manage applications in a multi-tenant architecture.
OpenAI offers a range of services that can be integrated with Azure, including text and speech synthesis, language translation, and content moderation.
Azure Cognitive Services provides a unified gateway to access OpenAI services, making it easier to integrate their functionality into Azure applications.
The Azure OpenAI service is a managed service that provides a simple and secure way to access OpenAI models and capabilities.
This service allows developers to build and deploy AI-powered applications with minimal setup and configuration.
OpenAI services can be used to enhance the user experience in Azure applications, such as virtual assistants, chatbots, and language translation tools.
The Azure OpenAI service supports a variety of OpenAI models, including text generation, language translation, and image generation.
Developers can use the Azure OpenAI service to build custom AI models and integrate them with Azure applications.
This integration enables developers to leverage the strengths of both Azure and OpenAI to build more sophisticated and user-friendly applications.
Deployment and Management
Deploying your application to Azure simplifies your operational burden by allowing you to share model deployments among tenants.
To deploy your application to Azure, you can use Visual Studio 2022 to create a publish profile. This involves right-clicking on your project in the solution explorer, choosing Publish, and selecting Azure as the target.
You can then create a new App Service for your project and select your hosting plan and resource group. Creating a new publish profile allows you to connect an Azure SQL Database to your application.
To connect an Azure SQL Database to your application, you need to configure the database connection string in the publish profile. This involves selecting the new database you created in the elastic pool and providing the connection username and password.
Once you've connected your database, Visual Studio will build the project and publish it to Azure. This will deploy your application and configure it to use the new database within an elastic pool.
Tenant-Specific Model Deployment
You can create a model deployment for each tenant to meet their unique requirements. This is especially useful when a tenant has special needs that can't be met by a shared model deployment.
Common reasons to use dedicated model deployments for a tenant include quota and cost management, content filtering policies, model types and versions, tenant-specific fine-tuning, and data residency.
A dedicated model deployment has its own distinct URL, but the underlying models are shared with other Azure customers and use shared Azure infrastructure.
Azure OpenAI doesn't enforce access control for each model deployment, so your application needs to control which tenant can reach which model deployment.
Here are some scenarios where dedicated model deployments are useful:
- Tenants with specific model lifecycle or fine-tuning requirements
- Tenants with strict data residency needs
- Tenants who require their own model deployment for quota and cost management
Each dedicated model deployment has its own TPM allocation, which enables precise cost allocation and management for each tenant. This is especially useful when using provisioned throughput units (PTUs).
Management Service
You can simplify your operational burden by sharing a model deployment among tenants. This approach reduces the number of deployments to manage and model versions to track.
Sharing a model deployment among tenants is a good option if you can, but you should only create dedicated model deployments if you need the capabilities they offer. Dedicated deployments provide more control and isolation, but they also increase the operational burden.
To manage your tenants effectively, consider using a tenant management service. This service can help you create a new database for each tenant within an Azure SQL Elastic Pool.
You can use the Azure SDK NuGet packages to implement a tenant management service. This will allow you to create a new database for a tenant when you create a new tenant.
A shared Azure OpenAI instance can be deployed in each stamp, following the Deployment Stamps pattern. This can help you avoid cross-region traffic latency and support data residency requirements.
Testing Multi-Tenant Operations with Postman
When working with multi-tenant operations in Azure, testing with Postman is a crucial step.
You'll want to publish your changes to Azure and test creating a new tenant with Postman.
Remember to set hasIsolatedDatabase to true.
This will allow you to create a new tenant with an isolated database in your Azure SQL Elastic Pool, which you can confirm by looking at the API response.
The connection string will be for the new tenant database.
Security and Governance
In a multi-tenant architecture, security and governance are crucial to ensure the integrity and control of resources across different tenants. Organizing and managing multiple Azure subscriptions is essential to maintain a secure and compliant environment.
You should consider how you allocate tenant resources to subscriptions, as this will have a significant impact on your overall security posture. This is a critical aspect of governance that cannot be overlooked.
To streamline cross-tenant management experiences, you can use Azure Lighthouse to manage resources for multiple customers from within your own Microsoft Entra tenant. This allows you to perform many tasks and services across managed tenants using Azure delegated resource management.
Here are some key considerations for security and governance in Azure multi-tenant architecture:
- Azure Managed Applications provide a secure way to deploy resources to a resource group managed by the publisher of the app.
- The resource group is present in the consumer's subscription, but an identity in the publisher's tenant has access to the resource group.
Microsoft Well-Architected Framework
In a multitenant system, reliability is crucial to ensure that all tenants have a good experience. You should pay special attention to the Reliability pillar of the Microsoft Azure Well-Architected Framework.
The nature of cloud hosting leads to applications that are often multitenant, use shared platform services, compete for resources and bandwidth, communicate over the internet, and run on commodity hardware. This increases the likelihood of faults arising.
To mitigate this, consider using a dedicated Azure OpenAI service for each tenant, which provides high data and performance isolation. This approach is ideal for single tenant deployments requiring network isolation from other tenants.
Alternatively, you can use a shared Azure OpenAI service with dedicated model deployment per tenant, which offers medium data isolation and high performance isolation. This is suitable for tenants with specific model lifecycle or fine-tuning requirements.
Here's a summary of the deployment approaches:
By choosing the right deployment approach, you can ensure that your multitenant system is reliable and meets the needs of all your tenants.
Authentication and Authorization
Azure App Service can validate authentication tokens on behalf of your app, ensuring a secure authentication process.
If a request doesn't contain a token, the token is invalid, or the request isn't authorized, App Service can be configured to block the request or redirect to your identity provider so that the user can sign in.
You can configure Azure App Service to use the /common endpoint to validate user tokens from Azure Active Directory (Azure AD), making it a reliable choice for identity management.
This ensures that, regardless of the user's Azure AD tenant, their tokens are validated and accepted, streamlining the authentication process.
Azure App Service can also be integrated with Azure AD B2C for consumers' authentication, providing a robust solution for identity and access management.
Access Restrictions
Access restrictions can be used to specify the IP address ranges or virtual networks that are allowed to connect to your app.
You can use access restrictions to restrict traffic to your app, which is especially useful for multi-tenant solutions.
Be aware of the maximum number of access restriction rules, as exceeding this limit might require deploying a reverse proxy like Azure Front Door.
IP address ranges and virtual networks can be specified to determine which connections are allowed to your app.
Governance and Compliance
Governance and compliance are crucial aspects of maintaining a secure and organized cloud environment. To manage multiple Azure subscriptions effectively, it's essential to consider how you allocate tenant resources to subscriptions.
Organizing and managing multiple Azure subscriptions can be a challenge, but it's a necessary step in ensuring compliance and security. You can use Azure Lighthouse to manage resources across multiple customers from within your own Microsoft Entra tenant.
Azure Lighthouse allows you to perform many tasks and services across managed tenants using Azure delegated resource management. This feature provides a centralized way to manage resources, making it easier to maintain compliance and security.
A managed application is another way to manage resources in a secure and compliant manner. In a managed application, the resources are deployed to a resource group that's managed by the publisher of the app. This approach ensures that the publisher has access to the resource group, while the consumer still maintains control over their subscription.
Here are some key benefits of using managed applications:
- Centralized management of resources
- Improved compliance and security
- Easy access to resources for publishers
- Control over subscriptions for consumers
Antipatterns
Antipatterns can have a significant impact on the security and governance of a system. The Noisy Neighbor antipattern is a prime example, where the activity of one tenant can negatively affect another tenant's use of the system.
In the case of the Noisy Neighbor, this can lead to performance issues, errors, and even security vulnerabilities. The impact of the Noisy Neighbor can be far-reaching and devastating.
The Noisy Neighbor antipattern is just one of the many antipatterns that can compromise the security and governance of a system. It's essential to identify and address these antipatterns to maintain a secure and well-governed system.
Frequently Asked Questions
What are the different types of tenants in Azure?
There are two main types of tenants in Azure: Customer and Workflow. A Customer tenant is the most common type, referring to an Azure Active Directory tenant.
Sources
- https://learn.microsoft.com/en-us/azure/architecture/guide/multitenant/service/openai
- https://www.alifconsulting.com/post/azure-app-service-and-functions
- https://aspnano.com/deploy-multi-tenant-azure-elastic-database-pool/
- https://github.com/microsoftdocs/architecture-center/blob/main/docs/guide/multitenant/related-resources.md
- https://kateblog.io/azure/multi-tenant-architecture/
Featured Images: pexels.com