|
| 1 | +// ---------------------------------------------------------------------------------- |
| 2 | +// |
| 3 | +// Copyright Microsoft Corporation |
| 4 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +// you may not use this file except in compliance with the License. |
| 6 | +// You may obtain a copy of the License at |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// Unless required by applicable law or agreed to in writing, software |
| 9 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | +// See the License for the specific language governing permissions and |
| 12 | +// limitations under the License. |
| 13 | +// ---------------------------------------------------------------------------------- |
| 14 | + |
| 15 | +using System.Collections.Generic; |
| 16 | + |
| 17 | +namespace Microsoft.Azure.Commands.Common.Authentication.Abstractions |
| 18 | +{ |
| 19 | + /// <summary> |
| 20 | + /// The build-in endpoints settings of AzureEnvironment. |
| 21 | + /// </summary> |
| 22 | + public partial class AzureEnvironment |
| 23 | + { |
| 24 | + |
| 25 | + /// <summary> |
| 26 | + /// Get built-in endpoints of AzureCloud. |
| 27 | + /// </summary> |
| 28 | + private static AzureEnvironment GetBuiltInAzureCloud() |
| 29 | + { |
| 30 | + return new AzureEnvironment |
| 31 | + { |
| 32 | + Name = EnvironmentName.AzureCloud, |
| 33 | + Type = TypeBuiltIn, |
| 34 | + PublishSettingsFileUrl = AzureEnvironmentConstants.AzurePublishSettingsFileUrl, |
| 35 | + ServiceManagementUrl = AzureEnvironmentConstants.AzureServiceEndpoint, |
| 36 | + ResourceManagerUrl = AzureEnvironmentConstants.AzureResourceManagerEndpoint, |
| 37 | + ManagementPortalUrl = AzureEnvironmentConstants.AzureManagementPortalUrl, |
| 38 | + ActiveDirectoryAuthority = AzureEnvironmentConstants.AzureActiveDirectoryEndpoint, |
| 39 | + ActiveDirectoryServiceEndpointResourceId = AzureEnvironmentConstants.AzureServiceEndpoint, |
| 40 | + StorageEndpointSuffix = AzureEnvironmentConstants.AzureStorageEndpointSuffix, |
| 41 | + GalleryUrl = AzureEnvironmentConstants.GalleryEndpoint, |
| 42 | + SqlDatabaseDnsSuffix = AzureEnvironmentConstants.AzureSqlDatabaseDnsSuffix, |
| 43 | + GraphUrl = AzureEnvironmentConstants.AzureGraphEndpoint, |
| 44 | + TrafficManagerDnsSuffix = AzureEnvironmentConstants.AzureTrafficManagerDnsSuffix, |
| 45 | + AzureKeyVaultDnsSuffix = AzureEnvironmentConstants.AzureKeyVaultDnsSuffix, |
| 46 | + AzureKeyVaultServiceEndpointResourceId = AzureEnvironmentConstants.AzureKeyVaultServiceEndpointResourceId, |
| 47 | + AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix = AzureEnvironmentConstants.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix, |
| 48 | + AzureDataLakeStoreFileSystemEndpointSuffix = AzureEnvironmentConstants.AzureDataLakeStoreFileSystemEndpointSuffix, |
| 49 | + GraphEndpointResourceId = AzureEnvironmentConstants.AzureGraphEndpoint, |
| 50 | + DataLakeEndpointResourceId = AzureEnvironmentConstants.AzureDataLakeServiceEndpointResourceId, |
| 51 | + BatchEndpointResourceId = AzureEnvironmentConstants.BatchEndpointResourceId, |
| 52 | + ContainerRegistryEndpointSuffix = AzureEnvironmentConstants.AzureContainerRegistryEndpointSuffix, |
| 53 | + AdTenant = "Common", |
| 54 | + |
| 55 | + ExtendedProperties = |
| 56 | + { |
| 57 | + { ExtendedEndpoint.AzureAttestationServiceEndpointSuffix, AzureEnvironmentConstants.AzureAttestationServiceEndpointSuffix }, |
| 58 | + { ExtendedEndpoint.AzureAttestationServiceEndpointResourceId, AzureEnvironmentConstants.AzureAttestationServiceEndpointResourceId }, |
| 59 | + { ExtendedEndpoint.MicrosoftGraphEndpointResourceId, AzureEnvironmentConstants.AzureMicrosoftGraphEndpointResourceId }, |
| 60 | + { ExtendedEndpoint.MicrosoftGraphUrl, AzureEnvironmentConstants.AzureMicrosoftGraphUrl }, |
| 61 | + { ExtendedEndpoint.AzureSynapseAnalyticsEndpointSuffix, AzureEnvironmentConstants.AzureSynapseAnalyticsEndpointSuffix }, |
| 62 | + { ExtendedEndpoint.AzureSynapseAnalyticsEndpointResourceId, AzureEnvironmentConstants.AzureSynapseAnalyticsEndpointResourceId } |
| 63 | + } |
| 64 | + }; |
| 65 | + } |
| 66 | + |
| 67 | + /// <summary> |
| 68 | + /// Get built-in endpoints of AzureChinaCloud. |
| 69 | + /// </summary> |
| 70 | + private static AzureEnvironment GetBuiltInChinaAzureCloud() |
| 71 | + { |
| 72 | + return new AzureEnvironment |
| 73 | + { |
| 74 | + Name = EnvironmentName.AzureChinaCloud, |
| 75 | + Type = TypeBuiltIn, |
| 76 | + PublishSettingsFileUrl = AzureEnvironmentConstants.ChinaPublishSettingsFileUrl, |
| 77 | + ServiceManagementUrl = AzureEnvironmentConstants.ChinaServiceEndpoint, |
| 78 | + ResourceManagerUrl = AzureEnvironmentConstants.ChinaResourceManagerEndpoint, |
| 79 | + ManagementPortalUrl = AzureEnvironmentConstants.ChinaManagementPortalUrl, |
| 80 | + ActiveDirectoryAuthority = AzureEnvironmentConstants.ChinaActiveDirectoryEndpoint, |
| 81 | + ActiveDirectoryServiceEndpointResourceId = AzureEnvironmentConstants.ChinaServiceEndpoint, |
| 82 | + StorageEndpointSuffix = AzureEnvironmentConstants.ChinaStorageEndpointSuffix, |
| 83 | + GalleryUrl = AzureEnvironmentConstants.GalleryEndpoint, |
| 84 | + SqlDatabaseDnsSuffix = AzureEnvironmentConstants.ChinaSqlDatabaseDnsSuffix, |
| 85 | + GraphUrl = AzureEnvironmentConstants.ChinaGraphEndpoint, |
| 86 | + TrafficManagerDnsSuffix = AzureEnvironmentConstants.ChinaTrafficManagerDnsSuffix, |
| 87 | + AzureKeyVaultDnsSuffix = AzureEnvironmentConstants.ChinaKeyVaultDnsSuffix, |
| 88 | + AzureKeyVaultServiceEndpointResourceId = AzureEnvironmentConstants.ChinaKeyVaultServiceEndpointResourceId, |
| 89 | + AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix = null, |
| 90 | + AzureDataLakeStoreFileSystemEndpointSuffix = null, |
| 91 | + DataLakeEndpointResourceId = null, |
| 92 | + GraphEndpointResourceId = AzureEnvironmentConstants.ChinaGraphEndpoint, |
| 93 | + BatchEndpointResourceId = AzureEnvironmentConstants.ChinaBatchEndpointResourceId, |
| 94 | + ContainerRegistryEndpointSuffix = AzureEnvironmentConstants.ChinaContainerRegistryEndpointSuffix, |
| 95 | + AdTenant = "Common", |
| 96 | + |
| 97 | + ExtendedProperties = |
| 98 | + { |
| 99 | + { ExtendedEndpoint.MicrosoftGraphEndpointResourceId, AzureEnvironmentConstants.ChinaMicrosoftGraphEndpointResourceId }, |
| 100 | + { ExtendedEndpoint.MicrosoftGraphUrl, AzureEnvironmentConstants.ChinaMicrosoftGraphUrl }, |
| 101 | + { ExtendedEndpoint.AzureSynapseAnalyticsEndpointSuffix, AzureEnvironmentConstants.ChinaSynapseAnalyticsEndpointSuffix }, |
| 102 | + { ExtendedEndpoint.AzureSynapseAnalyticsEndpointResourceId, AzureEnvironmentConstants.ChinaSynapseAnalyticsEndpointResourceId } |
| 103 | + } |
| 104 | + }; |
| 105 | + } |
| 106 | + |
| 107 | + /// <summary> |
| 108 | + /// Get built-in endpoints of AzureUSGovernment. |
| 109 | + /// </summary> |
| 110 | + private static AzureEnvironment GetBuiltInUSGovernmentCloud() |
| 111 | + { |
| 112 | + return new AzureEnvironment |
| 113 | + { |
| 114 | + Name = EnvironmentName.AzureUSGovernment, |
| 115 | + Type = TypeBuiltIn, |
| 116 | + PublishSettingsFileUrl = AzureEnvironmentConstants.USGovernmentPublishSettingsFileUrl, |
| 117 | + ServiceManagementUrl = AzureEnvironmentConstants.USGovernmentServiceEndpoint, |
| 118 | + ResourceManagerUrl = AzureEnvironmentConstants.USGovernmentResourceManagerEndpoint, |
| 119 | + ManagementPortalUrl = AzureEnvironmentConstants.USGovernmentManagementPortalUrl, |
| 120 | + ActiveDirectoryAuthority = AzureEnvironmentConstants.USGovernmentActiveDirectoryEndpoint, |
| 121 | + ActiveDirectoryServiceEndpointResourceId = AzureEnvironmentConstants.USGovernmentServiceEndpoint, |
| 122 | + StorageEndpointSuffix = AzureEnvironmentConstants.USGovernmentStorageEndpointSuffix, |
| 123 | + GalleryUrl = AzureEnvironmentConstants.GalleryEndpoint, |
| 124 | + SqlDatabaseDnsSuffix = AzureEnvironmentConstants.USGovernmentSqlDatabaseDnsSuffix, |
| 125 | + GraphUrl = AzureEnvironmentConstants.USGovernmentGraphEndpoint, |
| 126 | + TrafficManagerDnsSuffix = AzureEnvironmentConstants.USGovernmentTrafficManagerDnsSuffix, |
| 127 | + AzureKeyVaultDnsSuffix = AzureEnvironmentConstants.USGovernmentKeyVaultDnsSuffix, |
| 128 | + AzureKeyVaultServiceEndpointResourceId = AzureEnvironmentConstants.USGovernmentKeyVaultServiceEndpointResourceId, |
| 129 | + AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix = null, |
| 130 | + AzureDataLakeStoreFileSystemEndpointSuffix = null, |
| 131 | + DataLakeEndpointResourceId = null, |
| 132 | + GraphEndpointResourceId = AzureEnvironmentConstants.USGovernmentGraphEndpoint, |
| 133 | + BatchEndpointResourceId = AzureEnvironmentConstants.USGovernmentBatchEndpointResourceId, |
| 134 | + ContainerRegistryEndpointSuffix = AzureEnvironmentConstants.USGovernmentContainerRegistryEndpointSuffix, |
| 135 | + AdTenant = "Common", |
| 136 | + |
| 137 | + ExtendedProperties = |
| 138 | + { |
| 139 | + { ExtendedEndpoint.MicrosoftGraphEndpointResourceId, AzureEnvironmentConstants.USGovernmentMicrosoftGraphEndpointResourceId }, |
| 140 | + { ExtendedEndpoint.MicrosoftGraphUrl, AzureEnvironmentConstants.USGovernmentMicrosoftGraphUrl }, |
| 141 | + { ExtendedEndpoint.AzureSynapseAnalyticsEndpointSuffix, AzureEnvironmentConstants.USGovernmentSynapseAnalyticsEndpointSuffix }, |
| 142 | + { ExtendedEndpoint.AzureSynapseAnalyticsEndpointResourceId, AzureEnvironmentConstants.USGovernmentAnalysisServicesEndpointResourceId } |
| 143 | + } |
| 144 | + }; |
| 145 | + } |
| 146 | + |
| 147 | + /// <summary> |
| 148 | + /// Set Extended properties (to maintain parity). |
| 149 | + /// </summary> |
| 150 | + /// <param name="azureEnvironments">Collection of AzureEnvironments</param> |
| 151 | + private static void SetExtendedProperties(IDictionary<string, AzureEnvironment> azureEnvironments) |
| 152 | + { |
| 153 | + if (azureEnvironments.ContainsKey(EnvironmentName.AzureCloud)) |
| 154 | + { |
| 155 | + azureEnvironments[EnvironmentName.AzureCloud].SetProperty(ExtendedEndpoint.OperationalInsightsEndpoint, AzureEnvironmentConstants.AzureOperationalInsightsEndpoint); |
| 156 | + azureEnvironments[EnvironmentName.AzureCloud].SetProperty(ExtendedEndpoint.OperationalInsightsEndpointResourceId, AzureEnvironmentConstants.AzureOperationalInsightsEndpointResourceId); |
| 157 | + azureEnvironments[EnvironmentName.AzureCloud].SetProperty(ExtendedEndpoint.AnalysisServicesEndpointSuffix, AzureEnvironmentConstants.AzureAnalysisServicesEndpointSuffix); |
| 158 | + azureEnvironments[EnvironmentName.AzureCloud].SetProperty(ExtendedEndpoint.AnalysisServicesEndpointResourceId, AzureEnvironmentConstants.AzureAnalysisServicesEndpointResourceId); |
| 159 | + azureEnvironments[EnvironmentName.AzureCloud].SetProperty(ExtendedEndpoint.ManagedHsmServiceEndpointResourceId, AzureEnvironmentConstants.AzureManagedHsmServiceEndpointResourceId); |
| 160 | + azureEnvironments[EnvironmentName.AzureCloud].SetProperty(ExtendedEndpoint.ManagedHsmServiceEndpointSuffix, AzureEnvironmentConstants.AzureManagedHsmDnsSuffix); |
| 161 | + azureEnvironments[EnvironmentName.AzureCloud].SetProperty(ExtendedEndpoint.AzurePurviewEndpointSuffix, AzureEnvironmentConstants.AzurePurviewEndpointSuffix); |
| 162 | + azureEnvironments[EnvironmentName.AzureCloud].SetProperty(ExtendedEndpoint.AzurePurviewEndpointResourceId, AzureEnvironmentConstants.AzurePurviewEndpointResourceId); |
| 163 | + azureEnvironments[EnvironmentName.AzureCloud].SetProperty(ExtendedEndpoint.AzureAppConfigurationEndpointSuffix, AzureEnvironmentConstants.AzureAppConfigurationEndpointSuffix); |
| 164 | + azureEnvironments[EnvironmentName.AzureCloud].SetProperty(ExtendedEndpoint.AzureAppConfigurationEndpointResourceId, AzureEnvironmentConstants.AzureAppConfigurationEndpointResourceId); |
| 165 | + azureEnvironments[EnvironmentName.AzureCloud].SetProperty(ExtendedEndpoint.ContainerRegistryEndpointResourceId, AzureEnvironmentConstants.AzureContainerRegistryEndpointResourceId); |
| 166 | + } |
| 167 | + |
| 168 | + if (azureEnvironments.ContainsKey(EnvironmentName.AzureChinaCloud)) |
| 169 | + { |
| 170 | + azureEnvironments[EnvironmentName.AzureChinaCloud].SetProperty(ExtendedEndpoint.OperationalInsightsEndpoint, AzureEnvironmentConstants.ChinaOperationalInsightsEndpoint); |
| 171 | + azureEnvironments[EnvironmentName.AzureChinaCloud].SetProperty(ExtendedEndpoint.OperationalInsightsEndpointResourceId, AzureEnvironmentConstants.ChinaOperationalInsightsEndpointResourceId); |
| 172 | + azureEnvironments[EnvironmentName.AzureChinaCloud].SetProperty(ExtendedEndpoint.AnalysisServicesEndpointSuffix, AzureEnvironmentConstants.ChinaAnalysisServicesEndpointSuffix); |
| 173 | + azureEnvironments[EnvironmentName.AzureChinaCloud].SetProperty(ExtendedEndpoint.AnalysisServicesEndpointResourceId, AzureEnvironmentConstants.ChinaAnalysisServicesEndpointResourceId); |
| 174 | + azureEnvironments[EnvironmentName.AzureChinaCloud].SetProperty(ExtendedEndpoint.ManagedHsmServiceEndpointResourceId, AzureEnvironmentConstants.ChinaManagedHsmServiceEndpointResourceId); |
| 175 | + azureEnvironments[EnvironmentName.AzureChinaCloud].SetProperty(ExtendedEndpoint.ManagedHsmServiceEndpointSuffix, AzureEnvironmentConstants.ChinaManagedHsmDnsSuffix); |
| 176 | + azureEnvironments[EnvironmentName.AzureChinaCloud].SetProperty(ExtendedEndpoint.ContainerRegistryEndpointResourceId, AzureEnvironmentConstants.ChinaContainerRegistryEndpointResourceId); |
| 177 | + } |
| 178 | + |
| 179 | + if (azureEnvironments.ContainsKey(EnvironmentName.AzureUSGovernment)) |
| 180 | + { |
| 181 | + azureEnvironments[EnvironmentName.AzureUSGovernment].SetProperty(ExtendedEndpoint.OperationalInsightsEndpoint, AzureEnvironmentConstants.USGovernmentOperationalInsightsEndpoint); |
| 182 | + azureEnvironments[EnvironmentName.AzureUSGovernment].SetProperty(ExtendedEndpoint.OperationalInsightsEndpointResourceId, AzureEnvironmentConstants.USGovernmentOperationalInsightsEndpointResourceId); |
| 183 | + azureEnvironments[EnvironmentName.AzureUSGovernment].SetProperty(ExtendedEndpoint.AnalysisServicesEndpointSuffix, AzureEnvironmentConstants.USGovernmentAnalysisServicesEndpointSuffix); |
| 184 | + azureEnvironments[EnvironmentName.AzureUSGovernment].SetProperty(ExtendedEndpoint.AnalysisServicesEndpointResourceId, AzureEnvironmentConstants.USGovernmentAnalysisServicesEndpointResourceId); |
| 185 | + azureEnvironments[EnvironmentName.AzureUSGovernment].SetProperty(ExtendedEndpoint.ManagedHsmServiceEndpointResourceId, AzureEnvironmentConstants.USGovernmeneManagedHsmServiceEndpointResourceId); |
| 186 | + azureEnvironments[EnvironmentName.AzureUSGovernment].SetProperty(ExtendedEndpoint.ManagedHsmServiceEndpointSuffix, AzureEnvironmentConstants.USGovernmentManagedHsmDnsSuffix); |
| 187 | + azureEnvironments[EnvironmentName.AzureUSGovernment].SetProperty(ExtendedEndpoint.ContainerRegistryEndpointResourceId, AzureEnvironmentConstants.USGovernmentContainerRegistryEndpointResourceId); |
| 188 | + } |
| 189 | + } |
| 190 | + } |
| 191 | +} |
0 commit comments