You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-sql/database/elastic-convert-to-use-elastic-tools.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -163,7 +163,7 @@ For information on common data architecture patterns of multi-tenant software-as
163
163
164
164
## Questions and feature requests
165
165
166
-
For questions, use the [Microsoft Q&A question page for SQL Database](/answers/topics/azure-sql-database.html) and for feature requests, add them to the [SQL Database feedback forum](https://feedback.azure.com/forums/217321-sql-database/).
166
+
For questions, use the [Microsoft Q&A question page for SQL Database](/answers/topics/azure-sql-database.html) and for feature requests, add them to the [SQL Database feedback forum](https://feedback.azure.com/d365community/forum/04fe6ee0-3b25-ec11-b6e6-000d3a4f0da0).
title: Distributed transactions across cloud databases (preview)
3
3
description: Overview of Elastic Database Transactions with Azure SQL Database and Azure SQL Managed Instance.
4
-
services: sql-database
5
4
ms.service: sql-database
6
5
ms.subservice: scale-out
7
6
ms.custom: sqldbrb=1
8
-
ms.devlang:
9
7
ms.topic: conceptual
10
8
author: scoriani
11
9
ms.author: scoriani
@@ -53,53 +51,51 @@ For Azure App Service, upgrades to the guest OS are currently not supported. For
53
51
Note that the installer for .NET 4.6.1 may require more temporary storage during the bootstrapping process on Azure cloud services than the installer for .NET 4.6. To ensure a successful installation, you need to increase temporary storage for your Azure cloud service in your ServiceDefinition.csdef file in the LocalResources section and the environment settings of your startup task, as shown in the following sample:
The following sample code uses the familiar programming experience with .NET System.Transactions. The TransactionScope class establishes an ambient transaction in .NET. (An “ambient transaction” is one that lives in the current thread.) All connections opened within the TransactionScope participate in the transaction. If different databases participate, the transaction is automatically elevated to a distributed transaction. The outcome of the transaction is controlled by setting the scope to complete to indicate a commit.
78
+
The following sample code uses the familiar programming experience with .NET System.Transactions. The TransactionScope class establishes an ambient transaction in .NET. (An "ambient transaction" is one that lives in the current thread.) All connections opened within the TransactionScope participate in the transaction. If different databases participate, the transaction is automatically elevated to a distributed transaction. The outcome of the transaction is controlled by setting the scope to complete to indicate a commit.
81
79
82
80
```csharp
83
-
using (varscope=newTransactionScope())
81
+
using (varscope=newTransactionScope())
82
+
{
83
+
using (varconn1=newSqlConnection(connStrDb1))
84
84
{
85
-
using (varconn1=newSqlConnection(connStrDb1))
86
-
{
87
-
conn1.Open();
88
-
SqlCommandcmd1=conn1.CreateCommand();
89
-
cmd1.CommandText=string.Format("insert into T1 values(1)");
90
-
cmd1.ExecuteNonQuery();
91
-
}
92
-
93
-
using (varconn2=newSqlConnection(connStrDb2))
94
-
{
95
-
conn2.Open();
96
-
varcmd2=conn2.CreateCommand();
97
-
cmd2.CommandText=string.Format("insert into T2 values(2)");
98
-
cmd2.ExecuteNonQuery();
99
-
}
100
-
101
-
scope.Complete();
85
+
conn1.Open();
86
+
SqlCommandcmd1=conn1.CreateCommand();
87
+
cmd1.CommandText=string.Format("insert into T1 values(1)");
88
+
cmd1.ExecuteNonQuery();
102
89
}
90
+
using (varconn2=newSqlConnection(connStrDb2))
91
+
{
92
+
conn2.Open();
93
+
varcmd2=conn2.CreateCommand();
94
+
cmd2.CommandText=string.Format("insert into T2 values(2)");
95
+
cmd2.ExecuteNonQuery();
96
+
}
97
+
scope.Complete();
98
+
}
103
99
```
104
100
105
101
### Sharded database applications
@@ -108,24 +104,22 @@ Elastic database transactions for SQL Database and Managed Instance also support
108
104
The following code sample illustrates this approach. It assumes that a variable called shardmap is used to represent a shard map from the elastic database client library:
109
105
110
106
```csharp
111
-
using (varscope=newTransactionScope())
107
+
using (varscope=newTransactionScope())
108
+
{
109
+
using (varconn1=shardmap.OpenConnectionForKey(tenantId1, credentialsStr))
110
+
{
111
+
SqlCommandcmd1=conn1.CreateCommand();
112
+
cmd1.CommandText=string.Format("insert into T1 values(1)");
113
+
cmd1.ExecuteNonQuery();
114
+
}
115
+
using (varconn2=shardmap.OpenConnectionForKey(tenantId2, credentialsStr))
112
116
{
113
-
using (varconn1=shardmap.OpenConnectionForKey(tenantId1, credentialsStr))
114
-
{
115
-
SqlCommandcmd1=conn1.CreateCommand();
116
-
cmd1.CommandText=string.Format("insert into T1 values(1)");
117
-
cmd1.ExecuteNonQuery();
118
-
}
119
-
120
-
using (varconn2=shardmap.OpenConnectionForKey(tenantId2, credentialsStr))
121
-
{
122
-
varcmd2=conn2.CreateCommand();
123
-
cmd2.CommandText=string.Format("insert into T1 values(2)");
124
-
cmd2.ExecuteNonQuery();
125
-
}
126
-
127
-
scope.Complete();
117
+
varcmd2=conn2.CreateCommand();
118
+
cmd2.CommandText=string.Format("insert into T1 values(2)");
119
+
cmd2.ExecuteNonQuery();
128
120
}
121
+
scope.Complete();
122
+
}
129
123
```
130
124
131
125
## Transact-SQL development experience
@@ -135,35 +129,32 @@ A server-side distributed transactions using Transact-SQL are available only for
135
129
The following sample Transact-SQL code uses [BEGIN DISTRIBUTED TRANSACTION](/sql/t-sql/language-elements/begin-distributed-transaction-transact-sql) to start distributed transaction.
136
130
137
131
```Transact-SQL
138
-
139
-
-- Configure the Linked Server
140
-
-- Add one Azure SQL Managed Instance as Linked Server
Copy file name to clipboardExpand all lines: articles/azure-sql/database/saas-tenancy-elastic-tools-multi-tenant-row-level-security.md
+4-5Lines changed: 4 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,6 @@
1
1
---
2
2
title: Multi-tenant apps with RLS and elastic database tools
3
3
description: Use elastic database tools with row-level security to build an application with a highly scalable data tier.
4
-
services: sql-database
5
4
ms.service: sql-database
6
5
ms.subservice: scenario
7
6
ms.custom: sqldbrb=1
@@ -40,7 +39,7 @@ The goal is to use the elastic database client library [data-dependent routing](
40
39
41
40
This project extends the one described in [Elastic DB Tools for Azure SQL - Entity Framework Integration](elastic-scale-use-entity-framework-applications-visual-studio.md) by adding support for multi-tenant shard databases. The project builds a simple console application for creating blogs and posts. The project includes four tenants, plus two multi-tenant shard databases. This configuration is illustrated in the preceding diagram.
42
41
43
-
Build and run the application. This run bootstraps the elastic database tools’ shard map manager, and performs the following tests:
42
+
Build and run the application. This run bootstraps the elastic database tools' shard map manager, and performs the following tests:
44
43
45
44
1. Using Entity Framework and LINQ, create a new blog and then display all blogs for each tenant
46
45
2. Using ADO.NET SqlClient, display all blogs for a tenant
@@ -233,7 +232,7 @@ CREATE FUNCTION rls.fn_tenantAccessPredicate(@TenantId int)
233
232
WITH SCHEMABINDING
234
233
AS
235
234
RETURN SELECT1AS fn_accessResult
236
-
-- Use the user in your application’s connection string.
235
+
-- Use the user in your application's connection string.
237
236
-- Here we use 'dbo' only for demo purposes!
238
237
WHERE DATABASE_PRINCIPAL_ID() = DATABASE_PRINCIPAL_ID('dbo')
239
238
AND CAST(SESSION_CONTEXT(N'TenantId') ASint) = @TenantId;
@@ -340,7 +339,7 @@ GO
340
339
341
340
## Summary
342
341
343
-
Elastic database tools and row-level security can be used together to scale out an application’s data tier with support for both multi-tenant and single-tenant shards. Multi-tenant shards can be used to store data more efficiently. This efficiency is pronounced where a large number of tenants have only a few rows of data. Single-tenant shards can support premium tenants which have stricter performance and isolation requirements. For more information, see [Row-Level Security reference][rls].
342
+
Elastic database tools and row-level security can be used together to scale out an application's data tier with support for both multi-tenant and single-tenant shards. Multi-tenant shards can be used to store data more efficiently. This efficiency is pronounced where a large number of tenants have only a few rows of data. Single-tenant shards can support premium tenants which have stricter performance and isolation requirements. For more information, see [Row-Level Security reference][rls].
344
343
345
344
## Additional resources
346
345
@@ -352,7 +351,7 @@ Elastic database tools and row-level security can be used together to scale out
352
351
353
352
## Questions and Feature Requests
354
353
355
-
For questions, contact us on the [Microsoft Q&A question page for SQL Database](/answers/topics/azure-sql-database.html). And add any feature requests to the [SQL Database feedback forum](https://feedback.azure.com/forums/217321-sql-database/).
354
+
For questions, contact us on the [Microsoft Q&A question page for SQL Database](/answers/topics/azure-sql-database.html). And add any feature requests to the [SQL Database feedback forum](https://feedback.azure.com/d365community/forum/04fe6ee0-3b25-ec11-b6e6-000d3a4f0da0).
0 commit comments