From 63c6846bce0a528ac92f8f86e21cfcd117c87fe8 Mon Sep 17 00:00:00 2001 From: Anthony Martin <38542602+anthony-c-martin@users.noreply.github.com> Date: Tue, 19 Nov 2024 16:51:15 -0500 Subject: [PATCH] Support deploying to other clouds in Deploy Pane --- .../apps/deploy-pane/src/components/hooks/useAzure.ts | 1 + src/vscode-bicep-ui/apps/deploy-pane/src/models.ts | 1 + src/vscode-bicep/src/azure/AzureUiManager.ts | 4 ++++ src/vscode-bicep/src/azure/types.ts | 1 + src/vscode-bicep/src/panes/deploy/view.ts | 10 +++++++++- 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/vscode-bicep-ui/apps/deploy-pane/src/components/hooks/useAzure.ts b/src/vscode-bicep-ui/apps/deploy-pane/src/components/hooks/useAzure.ts index bb74d8cb7dc..7d9f611a1f8 100644 --- a/src/vscode-bicep-ui/apps/deploy-pane/src/components/hooks/useAzure.ts +++ b/src/vscode-bicep-ui/apps/deploy-pane/src/components/hooks/useAzure.ts @@ -45,6 +45,7 @@ export function useAzure(props: UseAzureProps) { userAgentOptions: { userAgentPrefix: "bicepdeploypane", }, + endpoint: scope.armUrl, }); } diff --git a/src/vscode-bicep-ui/apps/deploy-pane/src/models.ts b/src/vscode-bicep-ui/apps/deploy-pane/src/models.ts index a5d5607666e..9d9e959f4f1 100644 --- a/src/vscode-bicep-ui/apps/deploy-pane/src/models.ts +++ b/src/vscode-bicep-ui/apps/deploy-pane/src/models.ts @@ -4,6 +4,7 @@ import type { ErrorResponse } from "@azure/arm-resources"; type DeploymentScopeBase = { + armUrl: string; portalUrl: string; tenantId: string; } & T; diff --git a/src/vscode-bicep/src/azure/AzureUiManager.ts b/src/vscode-bicep/src/azure/AzureUiManager.ts index 741338f2fa7..2b739750131 100644 --- a/src/vscode-bicep/src/azure/AzureUiManager.ts +++ b/src/vscode-bicep/src/azure/AzureUiManager.ts @@ -25,6 +25,7 @@ export class AzureUiManager implements IAzureUiManager { return { scopeType, + armUrl: subscription.environment.resourceManagerEndpointUrl, portalUrl: subscription.environment.portalUrl, tenantId: subscription.tenantId, subscriptionId: subscription.subscriptionId, @@ -36,6 +37,7 @@ export class AzureUiManager implements IAzureUiManager { const location = await this.azurePickers.pickLocation(this.context, subscription); return { scopeType, + armUrl: subscription.environment.resourceManagerEndpointUrl, portalUrl: subscription.environment.portalUrl, tenantId: subscription.tenantId, subscriptionId: subscription.subscriptionId, @@ -50,6 +52,7 @@ export class AzureUiManager implements IAzureUiManager { return { scopeType, + armUrl: subscription.environment.resourceManagerEndpointUrl, portalUrl: subscription.environment.portalUrl, tenantId: subscription.tenantId, managementGroup: nonNullProp(managementGroup, "name"), @@ -64,6 +67,7 @@ export class AzureUiManager implements IAzureUiManager { return { scopeType, + armUrl: subscription.environment.resourceManagerEndpointUrl, portalUrl: subscription.environment.portalUrl, tenantId: subscription.tenantId, associatedSubscriptionId: subscription.subscriptionId, diff --git a/src/vscode-bicep/src/azure/types.ts b/src/vscode-bicep/src/azure/types.ts index bdc458b30c9..74458c886e9 100644 --- a/src/vscode-bicep/src/azure/types.ts +++ b/src/vscode-bicep/src/azure/types.ts @@ -3,6 +3,7 @@ import { AccessToken } from "@azure/identity"; type DeploymentScopeBase = { + armUrl: string; portalUrl: string; tenantId: string; } & T; diff --git a/src/vscode-bicep/src/panes/deploy/view.ts b/src/vscode-bicep/src/panes/deploy/view.ts index 3731ec54b80..41ae4099c54 100644 --- a/src/vscode-bicep/src/panes/deploy/view.ts +++ b/src/vscode-bicep/src/panes/deploy/view.ts @@ -2,6 +2,7 @@ // Licensed under the MIT License. import crypto from "crypto"; import path from "path"; +import { Environment } from "@azure/ms-rest-azure-env"; import { callWithTelemetryAndErrorHandlingSync, IActionContext } from "@microsoft/vscode-azext-utils"; import fse from "fs-extra"; import vscode, { ExtensionContext } from "vscode"; @@ -251,6 +252,13 @@ export class DeployPaneView extends Disposable { vscode.Uri.joinPath(this.extensionUri, "out", "deploy-pane", "assets", "index.css"), ); + const armEndpoints = [ + Environment.AzureCloud, + Environment.ChinaCloud, + Environment.GermanCloud, + Environment.USGovernment, + ].map(env => env.resourceManagerEndpointUrl); + return ` @@ -260,7 +268,7 @@ export class DeployPaneView extends Disposable { Use a content security policy to only allow loading images from our extension directory, and only allow scripts that have a specific nonce. --> - +