Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add service tree id setting into azure publishing #9772

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions extensions/azurePublish/src/components/azureProvisionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ type ProvisionFormData = {
appServiceOperatingSystem: string;
enabledResources: ResourcesItem[];
requiredResources: ResourcesItem[];
serviceManagementReference: string;
};

// ---------- Styles ---------- //
Expand Down Expand Up @@ -336,6 +337,7 @@ const getDefaultFormData = (currentProfile, defaults) => {
currentProfile?.settings?.appServiceOperatingSystem ?? defaults.appServiceOperatingSystem,
enabledResources: defaults.enabledResources ?? [],
requiredResources: defaults.requireResources ?? [],
serviceManagementReference: '',
};
};

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -963,6 +969,35 @@ export const AzureProvisionDialog: React.FC = () => {
}}
/>
</Stack>
<Stack horizontal tokens={configureResourcePropertyStackTokens} verticalAlign="start">
<Stack>
<Stack
horizontal
styles={configureResourcePropertyLabelStackStyles}
tokens={{ childrenGap: 12 }}
verticalAlign="center"
>
<ConfigureResourcesPropertyLabel>
{formatMessage('Service Tree ID (optional)')}
</ConfigureResourcesPropertyLabel>
{renderPropertyInfoIcon(
formatMessage(
'Service Tree is a Microsoft tool to keep track of contact information for applications.',
),
)}
</Stack>
<LearnMoreLink href="https://go.microsoft.com/fwlink/?linkid=2184101" target="_blank">
{formatMessage('Learn more')}
</LearnMoreLink>
</Stack>
<TextField
disabled={currentConfig?.hostname || currentConfig?.name}
placeholder={formatMessage('e.g. 2ff8c055-d9e6-4485-8163-c02a43baaa6f')}
styles={configureResourceTextFieldStyles}
value={formData.serviceManagementReference}
onChange={newServiceTreeId}
/>
</Stack>
</Stack>
</form>
</ScrollablePane>
Expand Down Expand Up @@ -1225,6 +1260,7 @@ export const AzureProvisionDialog: React.FC = () => {
appServiceOperatingSystem: formData.appServiceOperatingSystem,
type: publishType,
externalResources: selectedResources,
serviceManagementReference: formData.serviceManagementReference,
});
}}
/>
Expand Down
17 changes: 14 additions & 3 deletions extensions/azurePublish/src/node/provision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface ProvisionConfig {
*/
workerRuntime?: string;
choice?: string;
serviceManagementReference?: string;
[key: string]: any;
}

Expand Down Expand Up @@ -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({
Expand All @@ -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({
Expand Down Expand Up @@ -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;
Expand Down
Loading