"Elastic Database Transactions" 可以使用 Azure Functions and/or 应用服务吗?
Can "Elastic Database Transactions" work from Azure Functions and/or App Services?
跨多个 SQL Azure 数据库的 distributed transactions 文档提到了环境 OS 的来宾 运行 事务必须具有 .NET 4.6.1。 Azure Functions and/or 应用服务是否属于这种情况?
应用程序服务(和功能)在 .NET 4.7 上 运行:
(2017 年 8 月)
我刚刚使用以下代码测试了 Azure Web App 上的分布式事务。如果我在调用 scope.Complete 之前抛出异常,事务将回滚并且记录不会保存到表中。它证明 Azure App Services 确实支持弹性数据库事务。
using (var scope = new TransactionScope())
{
using (var conn1 = new SqlConnection(azureSqlConnStrDb1))
{
conn1.Open();
SqlCommand cmd1 = conn1.CreateCommand();
cmd1.CommandText = string.Format("insert into T1 values(3)");
cmd1.ExecuteNonQuery();
}
using (var conn2 = new SqlConnection(azureSqlConnStrDb2))
{
conn2.Open();
var cmd2 = conn2.CreateCommand();
cmd2.CommandText = string.Format("insert into T2 values(4)");
cmd2.ExecuteNonQuery();
}
throw new Exception("I am a exception");
scope.Complete();
}
跨多个 SQL Azure 数据库的 distributed transactions 文档提到了环境 OS 的来宾 运行 事务必须具有 .NET 4.6.1。 Azure Functions and/or 应用服务是否属于这种情况?
应用程序服务(和功能)在 .NET 4.7 上 运行:
(2017 年 8 月)
我刚刚使用以下代码测试了 Azure Web App 上的分布式事务。如果我在调用 scope.Complete 之前抛出异常,事务将回滚并且记录不会保存到表中。它证明 Azure App Services 确实支持弹性数据库事务。
using (var scope = new TransactionScope())
{
using (var conn1 = new SqlConnection(azureSqlConnStrDb1))
{
conn1.Open();
SqlCommand cmd1 = conn1.CreateCommand();
cmd1.CommandText = string.Format("insert into T1 values(3)");
cmd1.ExecuteNonQuery();
}
using (var conn2 = new SqlConnection(azureSqlConnStrDb2))
{
conn2.Open();
var cmd2 = conn2.CreateCommand();
cmd2.CommandText = string.Format("insert into T2 values(4)");
cmd2.ExecuteNonQuery();
}
throw new Exception("I am a exception");
scope.Complete();
}