[英]How to set the CONNECTION_OPTIONS = 'ApplicationIntent=ReadOnly' for elastic queries on Azure SQL?
I am accessing the other database using elastic queries.我正在使用弹性查询访问其他数据库。 The data source was created like this:
数据源是这样创建的:
CREATE EXTERNAL DATA SOURCE TheCompanyQueryDataSrc WITH (
TYPE = RDBMS,
--CONNECTION_OPTIONS = 'ApplicationIntent=ReadOnly',
CREDENTIAL = ElasticDBQueryCred,
LOCATION = 'thecompanysql.database.windows.net',
DATABASE_NAME = 'TheCompanyProd'
);
To reduce the database load, the read-only replica was created and should be used.为了减少数据库负载,创建了只读副本并且应该使用它。 As far as I understand it, I should add the
CONNECTION_OPTIONS = 'ApplicationIntent=ReadOnly'
(commented out in the above code).据我了解,我应该添加
CONNECTION_OPTIONS = 'ApplicationIntent=ReadOnly'
(在上面的代码中注释掉)。 However, I get only the Incorrect syntax near 'CONNECTION_OPTIONS'
但是,我只在
Incorrect syntax near 'CONNECTION_OPTIONS'
Both databases (the one that sets the connection + external tables, and the other to-be-read-only are at the same server (thecompanysql.database.windows.net). Both are set the compatibility lever SQL Server 2019 (150).两个数据库(设置连接+外部表的一个,另一个只读在同一台服务器(thecompanysql.database.windows.net)。两者都设置了兼容性杠杆SQL Server 2019(150) .
What else should I set to make it work?我还应该设置什么让它工作?
The CREATE EXTERNAL DATA SOURCE Syntax doesn't support the option CONNECTION_OPTIONS = 'ApplicationIntent=ReadOnly'
. CREATE EXTERNAL DATA SOURCE语法不支持选项
CONNECTION_OPTIONS = 'ApplicationIntent=ReadOnly'
。 We can't use that in the statements.我们不能在语句中使用它。
If you want achieve that readonly request, the way is that please use the user account which only has the readonly(db_reader) permission to login the external database.如果要实现该只读请求,方法是请使用只有只读(db_reader)权限的用户帐户登录外部数据库。
For example:例如:
CREATE MASTER KEY ENCRYPTION BY PASSWORD = '<password>' ;
CREATE DATABASE SCOPED CREDENTIAL SQL_Credential
WITH
IDENTITY = '<username>' -- readonly user account,
SECRET = '<password>' ;
CREATE EXTERNAL DATA SOURCE MyElasticDBQueryDataSrc
WITH
( TYPE = RDBMS ,
LOCATION = '<server_name>.database.windows.net' ,
DATABASE_NAME = 'Customers' ,
CREDENTIAL = SQL_Credential
) ;
Since the option is not supported, then we can't use it with elastic query.由于不支持该选项,因此我们不能将其与弹性查询一起使用。 The only way to connect to the Azure SQL data with SSMS is like this:
使用 SSMS 连接到 Azure SQL 数据的唯一方法是这样的:
HTH. HTH。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.