如何测试数据库是否托管在 SQL Azure 上?
是否可以测试数据库是否托管在 SQL Azure 上?我正在查看 EF6 的 SqlAzureExecutionStrategy 并且只想在数据库实际上是 SQL Azure 数据库时应用.
Is it possible to test whether a database is hosted on SQL Azure? I am looking at SqlAzureExecutionStrategy for EF6 and only want to apply if the database is actually SQL Azure database.
目前我正在测试应用程序是否在 Azure 中运行.但是,我们正在考虑允许客户端自己托管 DB,因此希望通过某种方式来确定 DB 是 SQL Server 还是 Azure SQL.
Currently I am testing if App is running within Azure. However we are looking at allowing clients to host DB themselves so would like some way to identify if DB is a SQL Server or Azure SQL.
假设 EF 不知道,因为它隐藏了实现细节.
Assume EF won't know as it is hiding the implementation details.
我猜可能只是一个配置设置.只是想知道这在技术上是否可行.
Could just have a config setting I guess. Just wondered if it was technically possible.
推荐答案
于 2021 年 8 月更新以与更新的文档保持一致
SELECT CASE ServerProperty('EngineEdition')
WHEN 1 THEN 'Personal'
WHEN 2 THEN 'Standard'
WHEN 3 THEN 'Enterprise'
WHEN 4 THEN 'Express'
WHEN 5 THEN 'SQL Database'
WHEN 6 THEN 'Azure Synapse Analytics'
WHEN 8 THEN 'Azure SQL Managed Instance'
WHEN 9 THEN 'Azure SQL Edge'
WHEN 11 THEN 'Azure Synapse serverless SQL pool'
ELSE 'Unknown'
END
http://technet.microsoft.com/en-us/library/ms174396.aspx
相关文章