2017-09-07 02:12:42 +03:00
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
// Licensed under the MIT License. See License.txt in the project root for license information.
|
|
|
|
|
2018-10-05 01:28:19 +03:00
|
|
|
export interface EnvironmentParameters {
|
2017-09-07 02:12:42 +03:00
|
|
|
/**
|
|
|
|
* The Environment name.
|
|
|
|
*/
|
|
|
|
readonly name: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The management portal URL.
|
|
|
|
*/
|
|
|
|
readonly portalUrl: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The management service endpoint.
|
|
|
|
*/
|
|
|
|
readonly managementEndpointUrl: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The resource management endpoint.
|
|
|
|
*/
|
|
|
|
readonly resourceManagerEndpointUrl: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Active Directory login endpoint.
|
|
|
|
*/
|
|
|
|
readonly activeDirectoryEndpointUrl: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The resource ID to obtain AD tokens for (token audience).
|
|
|
|
*/
|
|
|
|
readonly activeDirectoryResourceId: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The publish settings file URL.
|
|
|
|
*/
|
|
|
|
readonly publishingProfileUrl?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The sql server management endpoint for mobile commands.
|
|
|
|
*/
|
|
|
|
readonly sqlManagementEndpointUrl?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The dns suffix for sql servers.
|
|
|
|
*/
|
|
|
|
readonly sqlServerHostnameSuffix?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The template gallery endpoint.
|
|
|
|
*/
|
|
|
|
readonly galleryEndpointUrl?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Active Directory resource ID.
|
|
|
|
*/
|
|
|
|
readonly activeDirectoryGraphResourceId?: string;
|
|
|
|
|
2018-08-25 03:06:57 +03:00
|
|
|
/**
|
|
|
|
* The batch resource ID.
|
|
|
|
*/
|
|
|
|
readonly batchResourceId?: string;
|
|
|
|
|
2017-09-07 02:12:42 +03:00
|
|
|
/**
|
|
|
|
* The Active Directory api version.
|
|
|
|
*/
|
|
|
|
readonly activeDirectoryGraphApiVersion?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The endpoint suffix for storage accounts.
|
|
|
|
*/
|
|
|
|
readonly storageEndpointSuffix?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The keyvault service dns suffix.
|
|
|
|
*/
|
|
|
|
readonly keyVaultDnsSuffix?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The data lake store filesystem service dns suffix.
|
|
|
|
*/
|
|
|
|
readonly azureDataLakeStoreFileSystemEndpointSuffix?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The data lake analytics job and catalog service dns suffix.
|
|
|
|
*/
|
|
|
|
readonly azureDataLakeAnalyticsCatalogAndJobEndpointSuffix?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines whether the authentication endpoint should be validated with Azure AD. Default value is true.
|
|
|
|
*/
|
|
|
|
readonly validateAuthority?: boolean;
|
2017-09-17 05:55:41 +03:00
|
|
|
}
|
2017-09-07 02:12:42 +03:00
|
|
|
|
2018-10-05 01:28:19 +03:00
|
|
|
export class Environment {
|
2017-09-07 02:12:42 +03:00
|
|
|
/**
|
|
|
|
* The Environment name.
|
|
|
|
*/
|
|
|
|
readonly name: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The management portal URL.
|
|
|
|
*/
|
|
|
|
readonly portalUrl: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The management service endpoint.
|
|
|
|
*/
|
|
|
|
readonly managementEndpointUrl: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The resource management endpoint.
|
|
|
|
*/
|
|
|
|
readonly resourceManagerEndpointUrl: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Active Directory login endpoint.
|
|
|
|
*/
|
|
|
|
readonly activeDirectoryEndpointUrl: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The resource ID to obtain AD tokens for (token audience).
|
|
|
|
*/
|
|
|
|
readonly activeDirectoryResourceId: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The publish settings file URL.
|
|
|
|
*/
|
|
|
|
readonly publishingProfileUrl?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The sql server management endpoint for mobile commands.
|
|
|
|
*/
|
|
|
|
readonly sqlManagementEndpointUrl?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The dns suffix for sql servers.
|
|
|
|
*/
|
|
|
|
readonly sqlServerHostnameSuffix?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The template gallery endpoint.
|
|
|
|
*/
|
|
|
|
readonly galleryEndpointUrl?: string;
|
2018-08-25 02:03:07 +03:00
|
|
|
|
2018-08-25 01:43:37 +03:00
|
|
|
/**
|
|
|
|
* The batch resource ID.
|
|
|
|
*/
|
|
|
|
readonly batchResourceId?: string;
|
2017-09-07 02:12:42 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The Active Directory resource ID.
|
|
|
|
*/
|
|
|
|
readonly activeDirectoryGraphResourceId?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Active Directory api version.
|
|
|
|
*/
|
|
|
|
readonly activeDirectoryGraphApiVersion?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The endpoint suffix for storage accounts.
|
|
|
|
*/
|
|
|
|
readonly storageEndpointSuffix?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The keyvault service dns suffix.
|
|
|
|
*/
|
|
|
|
readonly keyVaultDnsSuffix?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The data lake store filesystem service dns suffix.
|
|
|
|
*/
|
|
|
|
readonly azureDataLakeStoreFileSystemEndpointSuffix?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The data lake analytics job and catalog service dns suffix.
|
|
|
|
*/
|
|
|
|
readonly azureDataLakeAnalyticsCatalogAndJobEndpointSuffix?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines whether the authentication endpoint should be validated with Azure AD. Default value is true.
|
|
|
|
*/
|
2018-08-25 03:06:57 +03:00
|
|
|
readonly validateAuthority: boolean = true;
|
2017-09-07 02:12:42 +03:00
|
|
|
|
2018-10-05 01:28:19 +03:00
|
|
|
constructor(parameters: EnvironmentParameters) {
|
2018-08-25 03:06:57 +03:00
|
|
|
|
|
|
|
if (!parameters || typeof parameters !== "object") {
|
|
|
|
throw new Error("'parameters' is a required parameter and must be of type 'object'.");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Validate required parameters
|
|
|
|
const requiredParams = ["name", "portalUrl", "managementEndpointUrl", "resourceManagerEndpointUrl",
|
|
|
|
"activeDirectoryEndpointUrl", "activeDirectoryResourceId"];
|
|
|
|
requiredParams.forEach(function (param) {
|
|
|
|
if (!(<any>parameters)[param] || typeof (<any>parameters)[param].valueOf() !== "string") {
|
|
|
|
throw new Error(`Please provide "${param}" for the environment and it must be of type "string".`);
|
2017-09-07 02:12:42 +03:00
|
|
|
}
|
2018-08-25 03:06:57 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
this.name = parameters.name;
|
|
|
|
this.portalUrl = parameters.portalUrl;
|
|
|
|
this.managementEndpointUrl = parameters.managementEndpointUrl;
|
|
|
|
this.resourceManagerEndpointUrl = parameters.resourceManagerEndpointUrl;
|
|
|
|
this.activeDirectoryEndpointUrl = parameters.activeDirectoryEndpointUrl;
|
|
|
|
this.activeDirectoryResourceId = parameters.activeDirectoryResourceId;
|
|
|
|
if (this.activeDirectoryGraphApiVersion) {
|
|
|
|
this.activeDirectoryGraphApiVersion = parameters.activeDirectoryGraphApiVersion;
|
|
|
|
}
|
|
|
|
if (this.activeDirectoryGraphResourceId) {
|
|
|
|
this.activeDirectoryGraphResourceId = parameters.activeDirectoryGraphResourceId;
|
|
|
|
}
|
|
|
|
if (this.azureDataLakeAnalyticsCatalogAndJobEndpointSuffix) {
|
|
|
|
this.azureDataLakeAnalyticsCatalogAndJobEndpointSuffix = parameters.azureDataLakeAnalyticsCatalogAndJobEndpointSuffix;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.azureDataLakeStoreFileSystemEndpointSuffix) {
|
|
|
|
this.azureDataLakeStoreFileSystemEndpointSuffix = parameters.azureDataLakeStoreFileSystemEndpointSuffix;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.batchResourceId) {
|
|
|
|
this.batchResourceId = parameters.batchResourceId;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.galleryEndpointUrl) {
|
|
|
|
this.galleryEndpointUrl = parameters.galleryEndpointUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.keyVaultDnsSuffix) {
|
|
|
|
this.keyVaultDnsSuffix = parameters.keyVaultDnsSuffix;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.publishingProfileUrl) {
|
|
|
|
this.publishingProfileUrl = parameters.publishingProfileUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.sqlManagementEndpointUrl) {
|
|
|
|
this.sqlManagementEndpointUrl = parameters.sqlManagementEndpointUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.sqlServerHostnameSuffix) {
|
|
|
|
this.sqlServerHostnameSuffix = parameters.sqlServerHostnameSuffix;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.storageEndpointSuffix) {
|
|
|
|
this.storageEndpointSuffix = parameters.storageEndpointSuffix;
|
2017-09-07 02:12:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-05 01:28:19 +03:00
|
|
|
static add(parameters: EnvironmentParameters): void {
|
|
|
|
const envContainer: { [name: string]: Environment } = {};
|
|
|
|
const envObj = new Environment(parameters);
|
2017-09-07 02:12:42 +03:00
|
|
|
envContainer[parameters.name] = envObj;
|
2018-10-05 01:28:19 +03:00
|
|
|
Object.assign(Environment, envContainer);
|
2017-09-07 02:12:42 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-10-05 01:28:19 +03:00
|
|
|
static get(name: string): Environment {
|
2017-09-07 02:12:42 +03:00
|
|
|
if (!name) {
|
|
|
|
throw new TypeError("name cannot be null or undefined and must be of type string.");
|
|
|
|
}
|
2018-10-05 01:28:19 +03:00
|
|
|
return (Environment as any)[name];
|
2017-09-07 02:12:42 +03:00
|
|
|
}
|
|
|
|
|
2018-10-05 01:28:19 +03:00
|
|
|
static readonly AzureCloud = {
|
|
|
|
name: "AzureCloud",
|
2017-09-17 05:55:41 +03:00
|
|
|
portalUrl: "https://portal.azure.com",
|
|
|
|
publishingProfileUrl: "https://go.microsoft.com/fwlink/?LinkId=254432",
|
|
|
|
managementEndpointUrl: "https://management.core.windows.net",
|
|
|
|
resourceManagerEndpointUrl: "https://management.azure.com/",
|
|
|
|
sqlManagementEndpointUrl: "https://management.core.windows.net:8443/",
|
|
|
|
sqlServerHostnameSuffix: ".database.windows.net",
|
|
|
|
galleryEndpointUrl: "https://gallery.azure.com/",
|
|
|
|
activeDirectoryEndpointUrl: "https://login.microsoftonline.com/",
|
|
|
|
activeDirectoryResourceId: "https://management.core.windows.net/",
|
|
|
|
activeDirectoryGraphResourceId: "https://graph.windows.net/",
|
2018-08-25 01:43:37 +03:00
|
|
|
batchResourceId: "https://batch.core.windows.net/",
|
2017-09-17 05:55:41 +03:00
|
|
|
activeDirectoryGraphApiVersion: "2013-04-05",
|
|
|
|
storageEndpointSuffix: ".core.windows.net",
|
|
|
|
keyVaultDnsSuffix: ".vault.azure.net",
|
|
|
|
azureDataLakeStoreFileSystemEndpointSuffix: "azuredatalakestore.net",
|
|
|
|
azureDataLakeAnalyticsCatalogAndJobEndpointSuffix: "azuredatalakeanalytics.net",
|
2017-09-07 02:12:42 +03:00
|
|
|
validateAuthority: true
|
|
|
|
};
|
2018-10-05 01:28:19 +03:00
|
|
|
static readonly ChinaCloud = {
|
|
|
|
name: "AzureChinaCloud",
|
2017-09-17 05:55:41 +03:00
|
|
|
portalUrl: "https://portal.azure.cn",
|
|
|
|
publishingProfileUrl: "https://go.microsoft.com/fwlink/?LinkID=301774",
|
|
|
|
managementEndpointUrl: "https://management.core.chinacloudapi.cn",
|
|
|
|
resourceManagerEndpointUrl: "https://management.chinacloudapi.cn",
|
|
|
|
sqlManagementEndpointUrl: "https://management.core.chinacloudapi.cn:8443/",
|
|
|
|
sqlServerHostnameSuffix: ".database.chinacloudapi.cn",
|
|
|
|
galleryEndpointUrl: "https://gallery.chinacloudapi.cn/",
|
|
|
|
activeDirectoryEndpointUrl: "https://login.chinacloudapi.cn/",
|
|
|
|
activeDirectoryResourceId: "https://management.core.chinacloudapi.cn/",
|
|
|
|
activeDirectoryGraphResourceId: "https://graph.chinacloudapi.cn/",
|
|
|
|
activeDirectoryGraphApiVersion: "2013-04-05",
|
2018-08-25 01:43:37 +03:00
|
|
|
batchResourceId: "https://batch.chinacloudapi.cn/",
|
2017-09-17 05:55:41 +03:00
|
|
|
storageEndpointSuffix: ".core.chinacloudapi.cn",
|
|
|
|
keyVaultDnsSuffix: ".vault.azure.cn",
|
2017-09-07 02:12:42 +03:00
|
|
|
// TODO: add dns suffixes for the china cloud for datalake store and datalake analytics once they are defined.
|
2017-09-17 05:55:41 +03:00
|
|
|
azureDataLakeStoreFileSystemEndpointSuffix: "N/A",
|
|
|
|
azureDataLakeAnalyticsCatalogAndJobEndpointSuffix: "N/A",
|
2017-09-07 02:12:42 +03:00
|
|
|
validateAuthority: true
|
|
|
|
};
|
2018-10-05 01:28:19 +03:00
|
|
|
static readonly USGovernment = {
|
2017-09-17 05:55:41 +03:00
|
|
|
name: "AzureUSGovernment",
|
|
|
|
portalUrl: "https://portal.azure.us",
|
|
|
|
publishingProfileUrl: "https://manage.windowsazure.us/publishsettings/index",
|
|
|
|
managementEndpointUrl: "https://management.core.usgovcloudapi.net",
|
|
|
|
resourceManagerEndpointUrl: "https://management.usgovcloudapi.net",
|
|
|
|
sqlManagementEndpointUrl: "https://management.core.usgovcloudapi.net:8443/",
|
|
|
|
sqlServerHostnameSuffix: ".database.usgovcloudapi.net",
|
|
|
|
galleryEndpointUrl: "https://gallery.usgovcloudapi.net/",
|
2018-08-28 18:47:56 +03:00
|
|
|
activeDirectoryEndpointUrl: "https://login.microsoftonline.us/",
|
2017-09-17 05:55:41 +03:00
|
|
|
activeDirectoryResourceId: "https://management.core.usgovcloudapi.net/",
|
|
|
|
activeDirectoryGraphResourceId: "https://graph.windows.net/",
|
2018-08-25 01:43:37 +03:00
|
|
|
batchResourceId: "https://batch.core.usgovcloudapi.net/",
|
2017-09-17 05:55:41 +03:00
|
|
|
activeDirectoryGraphApiVersion: "2013-04-05",
|
|
|
|
storageEndpointSuffix: ".core.usgovcloudapi.net",
|
|
|
|
keyVaultDnsSuffix: ".vault.usgovcloudapi.net",
|
|
|
|
azureDataLakeStoreFileSystemEndpointSuffix: "N/A",
|
|
|
|
azureDataLakeAnalyticsCatalogAndJobEndpointSuffix: "N/A",
|
2017-09-07 02:12:42 +03:00
|
|
|
validateAuthority: true
|
|
|
|
};
|
2018-10-05 01:28:19 +03:00
|
|
|
static readonly GermanCloud = {
|
2017-09-17 05:55:41 +03:00
|
|
|
name: "AzureGermanCloud",
|
|
|
|
portalUrl: "https://portal.microsoftazure.de/",
|
|
|
|
publishingProfileUrl: "https://manage.microsoftazure.de/publishsettings/index",
|
|
|
|
managementEndpointUrl: "https://management.core.cloudapi.de",
|
|
|
|
resourceManagerEndpointUrl: "https://management.microsoftazure.de",
|
|
|
|
sqlManagementEndpointUrl: "https://management.core.cloudapi.de:8443/",
|
|
|
|
sqlServerHostnameSuffix: ".database.cloudapi.de",
|
|
|
|
galleryEndpointUrl: "https://gallery.cloudapi.de/",
|
|
|
|
activeDirectoryEndpointUrl: "https://login.microsoftonline.de/",
|
|
|
|
activeDirectoryResourceId: "https://management.core.cloudapi.de/",
|
|
|
|
activeDirectoryGraphResourceId: "https://graph.cloudapi.de/",
|
2018-08-25 01:43:37 +03:00
|
|
|
batchResourceId: "https://batch.microsoftazure.de/",
|
2017-09-17 05:55:41 +03:00
|
|
|
activeDirectoryGraphApiVersion: "2013-04-05",
|
|
|
|
storageEndpointSuffix: ".core.cloudapi.de",
|
|
|
|
keyVaultDnsSuffix: ".vault.microsoftazure.de",
|
|
|
|
azureDataLakeStoreFileSystemEndpointSuffix: "N/A",
|
|
|
|
azureDataLakeAnalyticsCatalogAndJobEndpointSuffix: "N/A",
|
2017-09-07 02:12:42 +03:00
|
|
|
validateAuthority: true
|
|
|
|
};
|
2018-08-25 01:43:37 +03:00
|
|
|
}
|