-
Notifications
You must be signed in to change notification settings - Fork 136
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
Display a warning after deploying a blob trigger to a flex consumption app #4138
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
36f0fb8
Look for blobTrigger and only check for flex consumption
nturinski 56534f4
Make changes for looking at blob trigger
nturinski c87cdb4
Add a warning to deploying blobTriggers to flex apps
nturinski 87b75d4
Remove old comment
nturinski 28f14d0
Quick fix
nturinski f82a76f
Minor text change
nturinski 8d539c1
PR feedback
nturinski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,57 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { type FunctionEnvelope } from "@azure/arm-appservice"; | ||
import { DialogResponses, type IActionContext, type IAzureMessageOptions } from "@microsoft/vscode-azext-utils"; | ||
import * as retry from 'p-retry'; | ||
import { type WorkspaceFolder } from "vscode"; | ||
import { localize } from "../../localize"; | ||
import { type IBindingTemplate } from "../../templates/IBindingTemplate"; | ||
import { type SlotTreeItem } from "../../tree/SlotTreeItem"; | ||
import { getWorkspaceSetting, updateWorkspaceSetting } from "../../vsCodeConfig/settings"; | ||
|
||
export async function hasRemoteEventGridBlobTrigger(context: IActionContext, node: SlotTreeItem): Promise<boolean> { | ||
const retries = 3; | ||
const client = await node.site.createClient(context); | ||
|
||
const funcs = await retry<FunctionEnvelope[]>( | ||
async () => { | ||
// Load more currently broken https://github.com/Azure/azure-sdk-for-js/issues/20380 | ||
const response = await client.listFunctions(); | ||
const failedToList = localize('failedToList', 'Failed to list functions.'); | ||
|
||
// https://github.com/Azure/azure-functions-host/issues/3502 | ||
if (!Array.isArray(response)) { | ||
throw new Error(failedToList); | ||
} | ||
|
||
return response; | ||
}, | ||
{ retries, minTimeout: 10 * 1000 } | ||
); | ||
|
||
return funcs.some(f => { | ||
const bindings = (f.config as { bindings: IBindingTemplate[] }).bindings; | ||
return bindings.some(b => b.type === 'blobTrigger'); | ||
}); | ||
} | ||
|
||
export async function promptForEventGrid(context: IActionContext, workspaceFolder: WorkspaceFolder): Promise<void> { | ||
const showFlexEventGridWarning = await getWorkspaceSetting('showFlexEventGridWarning'); | ||
if (!showFlexEventGridWarning) { | ||
return; | ||
} | ||
|
||
const eventGridWarning = localize( | ||
'eventGridWarning', | ||
`Usage of an Event Grid based blob trigger requires an Event Grid subscription created on an Azure Storage v2 account. If you haven't already, you need to create a Event Grid subscription to complete your deployment.`); | ||
const options: IAzureMessageOptions = { learnMoreLink: 'https://aka.ms/learnMoreEventGridSubscription' }; | ||
// need to add don't show again | ||
const result = await context.ui.showWarningMessage(eventGridWarning, options, { title: 'Close' }, DialogResponses.dontWarnAgain); | ||
if (result === DialogResponses.dontWarnAgain) { | ||
await updateWorkspaceSetting('showFlexEventGridWarning', false, workspaceFolder); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Extra new line |
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this a todo comment?