-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create AI ARM 2.1 for Functions and App Service (#1200)
* Workaround for checkNameAvailability bug for site and slots * Create log analytics workspace to use for AI 2.1 * Update appservice/src/utils/azureClients.ts Co-authored-by: Brandon Waterloo [MSFT] <36966225+bwateratmsft@users.noreply.github.com> * Update appservice/src/createAppService/IAppServiceWizardContext.ts Co-authored-by: Brandon Waterloo [MSFT] <36966225+bwateratmsft@users.noreply.github.com> * Update appservice/src/createAppService/LogAnalyticsCreateStep.ts Co-authored-by: Brandon Waterloo [MSFT] <36966225+bwateratmsft@users.noreply.github.com> * Update appservice/src/createAppService/LogAnalyticsCreateStep.ts Co-authored-by: Brandon Waterloo [MSFT] <36966225+bwateratmsft@users.noreply.github.com> * Refactor out getAppInsightsSupprotedLocation and use it in LogAnalyticsCreateStep * Bump version * Minor fixes * PR feedback * Bump. Sorry for dismissing your review, Brandon Co-authored-by: Brandon Waterloo [MSFT] <36966225+bwateratmsft@users.noreply.github.com>
- Loading branch information
1 parent
e878f6e
commit 7df6b17
Showing
10 changed files
with
463 additions
and
236 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { AzExtLocation, getResourceGroupFromId, LocationListStep, uiUtils } from "@microsoft/vscode-azext-azureutils"; | ||
import { AzureWizardExecuteStep, nonNullProp, nonNullValueAndProp } from "@microsoft/vscode-azext-utils"; | ||
import { Progress } from "vscode"; | ||
import { ext } from "../extensionVariables"; | ||
import { localize } from "../localize"; | ||
import { createOperationalInsightsManagementClient } from "../utils/azureClients"; | ||
import { getAppInsightsSupportedLocation } from "./getAppInsightsSupportedLocation"; | ||
import { IAppServiceWizardContext } from "./IAppServiceWizardContext"; | ||
|
||
export class LogAnalyticsCreateStep extends AzureWizardExecuteStep<IAppServiceWizardContext> { | ||
public priority: number = 134; | ||
|
||
public async execute(context: IAppServiceWizardContext, progress: Progress<{ message?: string | undefined; increment?: number | undefined }>): Promise<void> { | ||
const opClient = await createOperationalInsightsManagementClient(context); | ||
const rgName = nonNullValueAndProp(context.resourceGroup, 'name'); | ||
const resourceLocation: AzExtLocation = await LocationListStep.getLocation(context); | ||
const location = await getAppInsightsSupportedLocation(context, resourceLocation); | ||
|
||
if (!location) { | ||
// if there is no supported AI location, then skip this as AppInsightsCreateStep will be skipped | ||
return; | ||
} | ||
|
||
const workspaces = await uiUtils.listAllIterator(opClient.workspaces.list()); | ||
const workspacesInSameLoc = workspaces.filter(ws => ws.location === location); | ||
const workspacesInSameRg = workspacesInSameLoc.filter(ws => getResourceGroupFromId(nonNullProp(ws, 'id')) === rgName); | ||
|
||
context.logAnalyticsWorkspace = workspacesInSameRg[0] ?? workspacesInSameLoc[0]; | ||
|
||
if (context.logAnalyticsWorkspace) { | ||
const usingLaw: string = localize('usingLogAnalyticsWorkspace', 'Using existing Log Analytics workspace "{0}"', context.logAnalyticsWorkspace.name); | ||
progress.report({ message: usingLaw }); | ||
ext.outputChannel.appendLog(usingLaw); | ||
} else { | ||
const creatingLaw: string = localize('creatingLogAnalyticsWorkspace', 'Creating new Log Analytics workspace...'); | ||
progress.report({ message: creatingLaw }); | ||
ext.outputChannel.appendLog(creatingLaw); | ||
const workspaceName = `workspace-${context.newAppInsightsName}` | ||
const createdLaw: string = localize('createdLogAnalyticWorkspace', 'Successfully created new Log Analytics workspace "{0}".', workspaceName); | ||
ext.outputChannel.appendLog(createdLaw); | ||
progress.report({ message: createdLaw }); | ||
context.logAnalyticsWorkspace = await opClient.workspaces.beginCreateOrUpdateAndWait(rgName, workspaceName, { location }); | ||
} | ||
} | ||
|
||
public shouldExecute(context: IAppServiceWizardContext): boolean { | ||
return !context.logAnalyticsWorkspace; | ||
} | ||
} |
Oops, something went wrong.