@@ -762,29 +762,53 @@ internal static Version GetAssemblyVersion()
762
762
private const string AZURE_SQL_CHINA = ".database.chinacloudapi.cn" ;
763
763
private const string AZURE_SQL_FABRIC = ".database.fabric.microsoft.com" ;
764
764
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>
775
771
internal static readonly string [ ] s_azureSqlServerEndpoints = { AZURE_SQL ,
776
772
AZURE_SQL_GERMANY ,
777
773
AZURE_SQL_USGOV ,
778
774
AZURE_SQL_CHINA ,
779
775
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 } ;
780
796
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
+
781
805
internal static bool IsAzureSqlServerEndpoint ( string dataSource )
782
806
{
783
- return IsEndpoint ( dataSource , null ) ;
807
+ return IsEndpoint ( dataSource , s_azureSqlServerEndpoints ) ;
784
808
}
785
809
786
810
// 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 )
788
812
{
789
813
int length = dataSource . Length ;
790
814
// remove server port
@@ -805,8 +829,6 @@ private static bool IsEndpoint(string dataSource, string prefix)
805
829
foundIndex = - 1 ;
806
830
}
807
831
808
-
809
-
810
832
if ( foundIndex > 0 )
811
833
{
812
834
length = foundIndex ;
@@ -819,10 +841,9 @@ private static bool IsEndpoint(string dataSource, string prefix)
819
841
}
820
842
821
843
// check if servername ends with any endpoints
822
- for ( int index = 0 ; index < s_azureSqlServerEndpoints . Length ; index ++ )
844
+ foreach ( var endpoint in endpoints )
823
845
{
824
- string endpoint = string . IsNullOrEmpty ( prefix ) ? s_azureSqlServerEndpoints [ index ] : prefix + s_azureSqlServerEndpoints [ index ] ;
825
- if ( length > endpoint . Length )
846
+ if ( length >= endpoint . Length )
826
847
{
827
848
if ( string . Compare ( dataSource , length - endpoint . Length , endpoint , 0 , endpoint . Length , StringComparison . OrdinalIgnoreCase ) == 0 )
828
849
{
0 commit comments