@@ -762,29 +762,53 @@ internal static Version GetAssemblyVersion()
762762 private const string AZURE_SQL_CHINA = ".database.chinacloudapi.cn" ;
763763 private const string AZURE_SQL_FABRIC = ".database.fabric.microsoft.com" ;
764764
765- internal static bool IsAzureSynapseOnDemandEndpoint ( string dataSource )
766- {
767- return IsEndpoint ( dataSource , ONDEMAND_PREFIX )
768- || dataSource . Contains ( AZURE_SYNAPSE )
769- || dataSource . Contains ( FABRIC_DATAWAREHOUSE )
770- || dataSource . Contains ( PBI_DATAWAREHOUSE )
771- || dataSource . Contains ( PBI_DATAWAREHOUSE2 )
772- || dataSource . Contains ( PBI_DATAWAREHOUSE3 ) ;
773- }
774-
765+ /// <summary>
766+ /// Represents a collection of Azure SQL Server endpoint URLs for various regions and environments.
767+ /// </summary>
768+ /// <remarks>This array includes endpoint URLs for Azure SQL in global, Germany, US Government,
769+ /// China, and Fabric environments. These endpoints are used to identify and interact with Azure SQL services
770+ /// in their respective regions or environments.</remarks>
775771 internal static readonly string [ ] s_azureSqlServerEndpoints = { AZURE_SQL ,
776772 AZURE_SQL_GERMANY ,
777773 AZURE_SQL_USGOV ,
778774 AZURE_SQL_CHINA ,
779775 AZURE_SQL_FABRIC } ;
776+
777+ /// <summary>
778+ /// Contains endpoint strings for Azure SQL Server on-demand services.
779+ /// Each entry is a combination of the ONDEMAND_PREFIX and a specific Azure SQL endpoint string.
780+ /// Example format: "ondemand.database.windows.net".
781+ /// </summary>
782+ internal static readonly string [ ] s_azureSqlServerOnDemandEndpoints = { ONDEMAND_PREFIX + AZURE_SQL ,
783+ ONDEMAND_PREFIX + AZURE_SQL_GERMANY ,
784+ ONDEMAND_PREFIX + AZURE_SQL_USGOV ,
785+ ONDEMAND_PREFIX + AZURE_SQL_CHINA ,
786+ ONDEMAND_PREFIX + AZURE_SQL_FABRIC } ;
787+ /// <summary>
788+ /// Represents a collection of endpoint identifiers for Azure Synapse and related services.
789+ /// </summary>
790+ /// <remarks>This array contains predefined endpoint strings used to identify Azure Synapse and
791+ /// associated services, such as Fabric Data Warehouse and Power BI Data Warehouse.</remarks>
792+ internal static readonly string [ ] s_azureSynapseEndpoints = { FABRIC_DATAWAREHOUSE ,
793+ PBI_DATAWAREHOUSE ,
794+ PBI_DATAWAREHOUSE2 ,
795+ PBI_DATAWAREHOUSE3 } ;
780796
797+ internal static readonly string [ ] s_azureSynapseOnDemandEndpoints = [ .. s_azureSqlServerOnDemandEndpoints , .. s_azureSynapseEndpoints ] ;
798+
799+ internal static bool IsAzureSynapseOnDemandEndpoint ( string dataSource )
800+ {
801+ return IsEndpoint ( dataSource , s_azureSynapseOnDemandEndpoints )
802+ || dataSource . IndexOf ( AZURE_SYNAPSE , StringComparison . OrdinalIgnoreCase ) >= 0 ;
803+ }
804+
781805 internal static bool IsAzureSqlServerEndpoint ( string dataSource )
782806 {
783- return IsEndpoint ( dataSource , null ) ;
807+ return IsEndpoint ( dataSource , s_azureSqlServerEndpoints ) ;
784808 }
785809
786810 // This method assumes dataSource parameter is in TCP connection string format.
787- private static bool IsEndpoint ( string dataSource , string prefix )
811+ private static bool IsEndpoint ( string dataSource , string [ ] endpoints )
788812 {
789813 int length = dataSource . Length ;
790814 // remove server port
@@ -805,8 +829,6 @@ private static bool IsEndpoint(string dataSource, string prefix)
805829 foundIndex = - 1 ;
806830 }
807831
808-
809-
810832 if ( foundIndex > 0 )
811833 {
812834 length = foundIndex ;
@@ -819,10 +841,9 @@ private static bool IsEndpoint(string dataSource, string prefix)
819841 }
820842
821843 // check if servername ends with any endpoints
822- for ( int index = 0 ; index < s_azureSqlServerEndpoints . Length ; index ++ )
844+ foreach ( var endpoint in endpoints )
823845 {
824- string endpoint = string . IsNullOrEmpty ( prefix ) ? s_azureSqlServerEndpoints [ index ] : prefix + s_azureSqlServerEndpoints [ index ] ;
825- if ( length > endpoint . Length )
846+ if ( length >= endpoint . Length )
826847 {
827848 if ( string . Compare ( dataSource , length - endpoint . Length , endpoint , 0 , endpoint . Length , StringComparison . OrdinalIgnoreCase ) == 0 )
828849 {
0 commit comments