Better error message when failing to list functions on linux (#635)
This commit is contained in:
Родитель
b325094498
Коммит
8d822ac20d
|
@ -18,6 +18,9 @@ All notable changes to the "azurefunctions" extension will be documented in this
|
|||
### [Fixed](https://github.com/Microsoft/vscode-azurefunctions/issues?q=is%3Aissue+milestone%3A%220.11.0%22+label%3Abug+is%3Aclosed)
|
||||
- "Copy Function Url" for v2 non-anonymous functions will copy an invalid url [#567](https://github.com/Microsoft/vscode-azurefunctions/issues/567)
|
||||
|
||||
### Known Issues
|
||||
- Functions cannot be listed for Linux Consumption apps [azure-functions-host#3502](https://github.com/Azure/azure-functions-host/issues/3502)
|
||||
|
||||
## 0.10.2 - 2018-09-10
|
||||
|
||||
### Fixed
|
||||
|
|
|
@ -130,24 +130,31 @@ export async function deploy(ui: IAzureUserInput, actionContext: IActionContext,
|
|||
}
|
||||
});
|
||||
|
||||
await listHttpTriggerUrls(node);
|
||||
await listHttpTriggerUrls(node, actionContext);
|
||||
}
|
||||
|
||||
async function listHttpTriggerUrls(node: IAzureParentNode): Promise<void> {
|
||||
const children: IAzureNode[] = await node.getCachedChildren();
|
||||
const functionsNode: IAzureParentNode<FunctionsTreeItem> = <IAzureParentNode<FunctionsTreeItem>>children.find((n: IAzureNode) => n.treeItem instanceof FunctionsTreeItem);
|
||||
await node.treeDataProvider.refresh(functionsNode);
|
||||
const functions: IAzureNode[] = await functionsNode.getCachedChildren();
|
||||
const anonFunctions: IAzureNode<FunctionTreeItem>[] = <IAzureNode<FunctionTreeItem>[]>functions.filter((f: IAzureNode) => f.treeItem instanceof FunctionTreeItem && f.treeItem.config.isHttpTrigger && f.treeItem.config.authLevel === HttpAuthLevel.anonymous);
|
||||
if (anonFunctions.length > 0) {
|
||||
ext.outputChannel.appendLine(localize('anonymousFunctionUrls', 'HTTP Trigger Urls:'));
|
||||
for (const func of anonFunctions) {
|
||||
ext.outputChannel.appendLine(` ${func.treeItem.label}: ${func.treeItem.triggerUrl}`);
|
||||
async function listHttpTriggerUrls(node: IAzureParentNode, actionContext: IActionContext): Promise<void> {
|
||||
try {
|
||||
const children: IAzureNode[] = await node.getCachedChildren();
|
||||
const functionsNode: IAzureParentNode<FunctionsTreeItem> = <IAzureParentNode<FunctionsTreeItem>>children.find((n: IAzureNode) => n.treeItem instanceof FunctionsTreeItem);
|
||||
await node.treeDataProvider.refresh(functionsNode);
|
||||
const functions: IAzureNode[] = await functionsNode.getCachedChildren();
|
||||
const anonFunctions: IAzureNode<FunctionTreeItem>[] = <IAzureNode<FunctionTreeItem>[]>functions.filter((f: IAzureNode) => f.treeItem instanceof FunctionTreeItem && f.treeItem.config.isHttpTrigger && f.treeItem.config.authLevel === HttpAuthLevel.anonymous);
|
||||
if (anonFunctions.length > 0) {
|
||||
ext.outputChannel.appendLine(localize('anonymousFunctionUrls', 'HTTP Trigger Urls:'));
|
||||
for (const func of anonFunctions) {
|
||||
ext.outputChannel.appendLine(` ${func.treeItem.label}: ${func.treeItem.triggerUrl}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (functions.find((f: IAzureNode) => f.treeItem instanceof FunctionTreeItem && f.treeItem.config.isHttpTrigger && f.treeItem.config.authLevel !== HttpAuthLevel.anonymous)) {
|
||||
ext.outputChannel.appendLine(localize('nonAnonymousWarning', 'WARNING: Some http trigger urls cannot be displayed in the output window because they require an authentication token. Instead, you may copy them from the Azure Functions explorer.'));
|
||||
if (functions.find((f: IAzureNode) => f.treeItem instanceof FunctionTreeItem && f.treeItem.config.isHttpTrigger && f.treeItem.config.authLevel !== HttpAuthLevel.anonymous)) {
|
||||
ext.outputChannel.appendLine(localize('nonAnonymousWarning', 'WARNING: Some http trigger urls cannot be displayed in the output window because they require an authentication token. Instead, you may copy them from the Azure Functions explorer.'));
|
||||
}
|
||||
} catch (error) {
|
||||
// suppress error notification and instead display a warning in the output. We don't want it to seem like the deployment failed.
|
||||
actionContext.suppressErrorDisplay = true;
|
||||
ext.outputChannel.appendLine(localize('failedToList', 'WARNING: Deployment succeeded, but failed to list http trigger urls.'));
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { FunctionEnvelope, FunctionEnvelopeCollection } from 'azure-arm-website/lib/models';
|
||||
import { isArray } from 'util';
|
||||
import { SiteClient } from 'vscode-azureappservice';
|
||||
import { createTreeItemsWithErrorHandling, IAzureNode, IAzureParentTreeItem, IAzureTreeItem } from 'vscode-azureextensionui';
|
||||
import { localize } from '../localize';
|
||||
|
@ -41,6 +42,12 @@ export class FunctionsTreeItem implements IAzureParentTreeItem {
|
|||
}
|
||||
|
||||
const funcs: FunctionEnvelopeCollection = this._nextLink ? await this._client.listFunctionsNext(this._nextLink) : await this._client.listFunctions();
|
||||
|
||||
// https://github.com/Azure/azure-functions-host/issues/3502
|
||||
if (!isArray(funcs)) {
|
||||
throw new Error(localize('failedToList', 'Failed to list functions.'));
|
||||
}
|
||||
|
||||
this._nextLink = funcs.nextLink;
|
||||
|
||||
return await createTreeItemsWithErrorHandling(
|
||||
|
|
Загрузка…
Ссылка в новой задаче