简体   繁体   English

如何为 Azure SQL 上的弹性查询设置 CONNECTION_OPTIONS = 'ApplicationIntent=ReadOnly'?

[英]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.

相关问题 带有ApplicationIntent ReadOnly的Azure SQL Server弹性查询 - Azure SQL Server Elastic query with ApplicationIntent ReadOnly 使用pymssql时如何传递连接参数“ ApplicationIntent = ReadOnly” - How to pass connection parameter “ApplicationIntent=ReadOnly” when using pymssql 如何在SQL命令中的Powershell代码中使用ApplicationIntent = ReadOnly - How to use ApplicationIntent=ReadOnly inside my powershell code in SQL command ApplicationIntent = ReadOnly在连接字符串中的含义是什么 - What does ApplicationIntent=ReadOnly mean in the connection string ApplicationIntent=ReadOnly 与 SQL Server 导入和导出向导 - ApplicationIntent=ReadOnly with SQL Server Import and Export Wizard 是否可以为连接到本地SQL Server的Azure数据工厂指定ApplicationIntent = ReadOnly? - Is it possible to specify ApplicationIntent = ReadOnly for Azure Data Factory connecting to on-premise SQL Server? 将sql server连接设置为只读? - set sql server connection to readonly? 与使用.Net代码处理跨数据库查询相比,使用Azure SQL弹性查询有什么好处? - What is the benefit of using Azure SQL elastic queries vs handling the cross DB queries in my .Net code? 如何通过从 SQL 服务器(本地)到 Azure SQL 数据库的查询/脚本设置定期迁移 - How to set up recurring migration through queries/script from SQL server(On-premise) to Azure SQL database 在 ApplicationIntent=ReadOnly 开启的情况下对链接服务器数据库使用 SELECT - Using SELECT against a linked server database with ApplicationIntent=ReadOnly turned on
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM