Adding support for multi cloud in azure rest api calls (#16454)

This commit is contained in:
Aasim Khan
2021-07-29 10:14:15 -07:00
committed by GitHub
parent 01671b118d
commit 0e9d956ee5
5 changed files with 51 additions and 5 deletions

View File

@@ -18,7 +18,8 @@ const enum SettingIds {
ossrdbms = 'ossrdbms', ossrdbms = 'ossrdbms',
vault = 'vault', vault = 'vault',
ado = 'ado', ado = 'ado',
ala = 'ala' ala = 'ala',
storage = 'storage'
} }
const publicAzureSettings: ProviderSettings = { const publicAzureSettings: ProviderSettings = {
@@ -74,6 +75,12 @@ const publicAzureSettings: ProviderSettings = {
endpoint: 'https://api.loganalytics.io', endpoint: 'https://api.loganalytics.io',
azureResourceId: AzureResource.AzureLogAnalytics, azureResourceId: AzureResource.AzureLogAnalytics,
}, },
azureStorageResource: {
id: SettingIds.storage,
endpoint: '',
endpointSuffix: '.core.windows.net',
azureResourceId: AzureResource.AzureStorage
},
redirectUri: 'https://vscode-redirect.azurewebsites.net/', redirectUri: 'https://vscode-redirect.azurewebsites.net/',
scopes: [ scopes: [
'openid', 'email', 'profile', 'offline_access', 'openid', 'email', 'profile', 'offline_access',
@@ -128,6 +135,12 @@ const usGovAzureSettings: ProviderSettings = {
endpoint: 'https://api.loganalytics.us', endpoint: 'https://api.loganalytics.us',
azureResourceId: AzureResource.AzureLogAnalytics, azureResourceId: AzureResource.AzureLogAnalytics,
}, },
azureStorageResource: {
id: SettingIds.storage,
endpoint: '',
endpointSuffix: '.core.usgovcloudapi.net',
azureResourceId: AzureResource.AzureStorage
},
redirectUri: 'https://vscode-redirect.azurewebsites.net/', redirectUri: 'https://vscode-redirect.azurewebsites.net/',
scopes: [ scopes: [
'openid', 'email', 'profile', 'offline_access', 'openid', 'email', 'profile', 'offline_access',
@@ -181,6 +194,12 @@ const usNatAzureSettings: ProviderSettings = {
endpoint: 'https://api.loganalytics.azure.eaglex.ic.gov', endpoint: 'https://api.loganalytics.azure.eaglex.ic.gov',
azureResourceId: AzureResource.AzureLogAnalytics, azureResourceId: AzureResource.AzureLogAnalytics,
}, },
azureStorageResource: {
id: SettingIds.storage,
endpoint: '',
endpointSuffix: '.core.eaglex.ic.gov',
azureResourceId: AzureResource.AzureStorage
},
redirectUri: 'https://vscode-redirect.azurewebsites.net/', redirectUri: 'https://vscode-redirect.azurewebsites.net/',
scopes: [ scopes: [
'openid', 'email', 'profile', 'offline_access', 'openid', 'email', 'profile', 'offline_access',
@@ -220,6 +239,12 @@ const germanyAzureSettings: ProviderSettings = {
endpoint: 'https://vault.microsoftazure.de', endpoint: 'https://vault.microsoftazure.de',
azureResourceId: AzureResource.AzureKeyVault azureResourceId: AzureResource.AzureKeyVault
}, },
azureStorageResource: {
id: SettingIds.storage,
endpoint: '',
endpointSuffix: '.core.cloudapi.de',
azureResourceId: AzureResource.AzureStorage
},
redirectUri: 'https://vscode-redirect.azurewebsites.net/', redirectUri: 'https://vscode-redirect.azurewebsites.net/',
scopes: [ scopes: [
'openid', 'email', 'profile', 'offline_access', 'openid', 'email', 'profile', 'offline_access',
@@ -273,6 +298,12 @@ const chinaAzureSettings: ProviderSettings = {
endpoint: 'https://api.loganalytics.azure.cn', endpoint: 'https://api.loganalytics.azure.cn',
azureResourceId: AzureResource.AzureLogAnalytics, azureResourceId: AzureResource.AzureLogAnalytics,
}, },
azureStorageResource: {
id: SettingIds.storage,
endpoint: '',
endpointSuffix: '.core.chinacloudapi.cn',
azureResourceId: AzureResource.AzureStorage
},
redirectUri: 'https://vscode-redirect.azurewebsites.net/', redirectUri: 'https://vscode-redirect.azurewebsites.net/',
scopes: [ scopes: [
'openid', 'email', 'profile', 'offline_access', 'openid', 'email', 'profile', 'offline_access',

View File

@@ -396,7 +396,7 @@ export async function makeHttpRequest(account: azdata.Account, subscription: azu
if (host) { if (host) {
requestUrl = `${host}${path}`; requestUrl = `${host}${path}`;
} else { } else {
requestUrl = `https://management.azure.com${path}`; requestUrl = `${account.properties.providerSettings.settings.armResource.endpoint}${path}`;
} }
let response; let response;
@@ -494,7 +494,7 @@ export async function getBlobs(account: azdata.Account, subscription: azureResou
try { try {
const sharedKeyCredential = new StorageSharedKeyCredential(storageAccount.name, storageKeys.keyName1); const sharedKeyCredential = new StorageSharedKeyCredential(storageAccount.name, storageKeys.keyName1);
const blobServiceClient = new BlobServiceClient( const blobServiceClient = new BlobServiceClient(
`https://${storageAccount.name}.blob.core.windows.net`, `https://${storageAccount.name}.blob${account.properties.providerSettings.settings.azureStorageResource.endpointSuffix}`,
sharedKeyCredential sharedKeyCredential
); );
const containerClient = blobServiceClient.getContainerClient(containerName); const containerClient = blobServiceClient.getContainerClient(containerName);

View File

@@ -123,6 +123,11 @@ declare module 'azurecore' {
*/ */
azureLogAnalyticsResource?: Resource; azureLogAnalyticsResource?: Resource;
/**
* Information that describes the Azure Storage resourceI
*/
azureStorageResource?: Resource;
/** /**
* A list of tenant IDs to authenticate against. If defined, then these IDs will be used * A list of tenant IDs to authenticate against. If defined, then these IDs will be used
* instead of querying the tenants endpoint of the armResource * instead of querying the tenants endpoint of the armResource
@@ -160,6 +165,11 @@ declare module 'azurecore' {
*/ */
endpoint: string; endpoint: string;
/**
* Endpoint suffix used to access the resource
*/
endpointSuffix?: string;
/** /**
* Resource ID for azdata * Resource ID for azdata
*/ */

View File

@@ -857,7 +857,11 @@ declare module 'azdata' {
/** /**
* Azure Log Analytics * Azure Log Analytics
*/ */
AzureLogAnalytics = 8 AzureLogAnalytics = 8,
/**
* Azure Storage
*/
AzureStorage = 9
} }
export interface ButtonProperties { export interface ButtonProperties {

View File

@@ -437,7 +437,8 @@ export enum AzureResource {
MicrosoftResourceManagement = 5, MicrosoftResourceManagement = 5,
AzureDevOps = 6, AzureDevOps = 6,
MsGraph = 7, MsGraph = 7,
AzureLogAnalytics = 8 AzureLogAnalytics = 8,
AzureStorage = 9
} }
export class TreeItem extends vsExtTypes.TreeItem { export class TreeItem extends vsExtTypes.TreeItem {