From dbf620a20dc838f1c4c6da2a3f69dd26ae3abe6e Mon Sep 17 00:00:00 2001 From: Eugene Olonov Date: Tue, 24 Sep 2024 16:47:02 -0700 Subject: [PATCH] feat: add service tree id setting into azure publishing --- .../src/components/azureProvisionDialog.tsx | 36 +++++++++++++++++++ extensions/azurePublish/src/node/provision.ts | 17 +++++++-- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/extensions/azurePublish/src/components/azureProvisionDialog.tsx b/extensions/azurePublish/src/components/azureProvisionDialog.tsx index a1ad56c572..4f5df666f7 100644 --- a/extensions/azurePublish/src/components/azureProvisionDialog.tsx +++ b/extensions/azurePublish/src/components/azureProvisionDialog.tsx @@ -76,6 +76,7 @@ type ProvisionFormData = { appServiceOperatingSystem: string; enabledResources: ResourcesItem[]; requiredResources: ResourcesItem[]; + serviceManagementReference: string; }; // ---------- Styles ---------- // @@ -336,6 +337,7 @@ const getDefaultFormData = (currentProfile, defaults) => { currentProfile?.settings?.appServiceOperatingSystem ?? defaults.appServiceOperatingSystem, enabledResources: defaults.enabledResources ?? [], requiredResources: defaults.requireResources ?? [], + serviceManagementReference: '', }; }; @@ -626,6 +628,10 @@ export const AzureProvisionDialog: React.FC = () => { [checkNameAvailability], ); + const newServiceTreeId = useCallback((e, serviceTreeId) => { + updateFormData('serviceManagementReference', serviceTreeId); + }, []); + const updateCurrentLocation = useCallback( (_e, option?: IDropdownOption) => { const location = deployLocations.find((t) => t.name === option?.key); @@ -963,6 +969,35 @@ export const AzureProvisionDialog: React.FC = () => { }} /> + + + + + {formatMessage('Service Tree ID (optional)')} + + {renderPropertyInfoIcon( + formatMessage( + 'Service Tree is a Microsoft tool to keep track of contact information for applications.', + ), + )} + + + {formatMessage('Learn more')} + + + + @@ -1225,6 +1260,7 @@ export const AzureProvisionDialog: React.FC = () => { appServiceOperatingSystem: formData.appServiceOperatingSystem, type: publishType, externalResources: selectedResources, + serviceManagementReference: formData.serviceManagementReference, }); }} /> diff --git a/extensions/azurePublish/src/node/provision.ts b/extensions/azurePublish/src/node/provision.ts index a30cb6716e..332d882640 100644 --- a/extensions/azurePublish/src/node/provision.ts +++ b/extensions/azurePublish/src/node/provision.ts @@ -30,6 +30,7 @@ export interface ProvisionConfig { */ workerRuntime?: string; choice?: string; + serviceManagementReference?: string; [key: string]: any; } @@ -89,7 +90,10 @@ export class BotProjectProvision { * create the applicationId for the bot registration * Docs: https://docs.microsoft.com/en-us/graph/api/application-post-applications?view=graph-rest-1.0&tabs=http */ - private async createApp(displayName: string): Promise<{ appId: string; appPassword: string }> { + private async createApp( + displayName: string, + serviceManagementReference: string | undefined, + ): Promise<{ appId: string; appPassword: string }> { const applicationUri = 'https://graph.microsoft.com/v1.0/applications'; this.logger({ @@ -116,7 +120,14 @@ export class BotProjectProvision { while (retryCount >= 0) { try { - const response = await axios.post(applicationUri, { displayName }, appCreateOptions); + const response = await axios.post( + applicationUri, + { + displayName, + ...(serviceManagementReference && { serviceManagementReference }), + }, + appCreateOptions, + ); appCreated = response.data; } catch (err) { this.logger({ @@ -295,7 +306,7 @@ export class BotProjectProvision { // Create the appId and appPassword - this is usually the first step. case AzureResourceTypes.APP_REGISTRATION: // eslint-disable-next-line no-case-declarations - const { appId, appPassword } = await this.createApp(config.hostname); + const { appId, appPassword } = await this.createApp(config.hostname, config.serviceManagementReference); provisionResults.appId = appId; provisionResults.appPassword = appPassword; break;