
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
@microsoft/vscode-azext-azureutils
Advanced tools
Common Azure utils for developing Azure extensions for VS Code
This package provides common Azure utilities for Azure VS Code extensions, and is intented to be used alongside @microsoft/vscode-azext-utils.
You must call registerAzureUtilsExtensionVariables
first in your extension's activate()
method. The first parameter of the function passed in will always be an IActionContext
, which allows you to specify custom telemetry and describes the behavior of this command. The simplest example is to register a command (in this case, refreshing a node):
registerAzureUtilsExtensionVariables(...);
registerCommand('yourExtension.Refresh', (context: IActionContext, node: AzExtTreeItem) => {
context.telemetry.properties.customProp = "example prop";
context.telemetry.measurements.customMeas = 49;
node.refresh();
});
Follow these steps to create your basic Azure Tree:
Create an AzExtTreeItem
(or AzExtParentTreeItem
) describing the items to be displayed under your subscription:
export class WebAppTreeItem extends AzExtTreeItem {
public static contextValue: string = "azureWebApp";
public readonly contextValue: string = WebAppTreeItem.contextValue;
private readonly _site: Site;
constructor(parent: AzExtParentTreeItem, site: Site) {
super(parent);
this._site = site;
}
public get id(): string {
return this._site.id;
}
public get label(): string {
return this._site.name;
}
}
Create a SubscriptionTreeItemBase
that provides the tree items you just implemented. It must implement at least hasMoreChildrenImpl
and loadMoreChildrenImpl
:
NOTE: Methods suffixed with
Impl
should not be called directly - just implemented.
export class SubscriptionTreeItem extends SubscriptionTreeItemBase {
private _nextLink: string | undefined;
public hasMoreChildrenImpl(): boolean {
return this._nextLink !== undefined;
}
public async loadMoreChildrenImpl(clearCache: boolean, _context: IActionContext): Promise<WebAppTreeItem[]> {
if (clearCache) {
this._nextLink = undefined;
}
const client: WebSiteManagementClient = createAzureClient(this.root, WebSiteManagementClient);
const webAppCollection: WebAppCollection = this._nextLink === undefined ?
await client.webApps.list() :
await client.webApps.listNext(this._nextLink);
this._nextLink = webAppCollection.nextLink;
return webAppCollection.map((site: Site) => new WebAppTreeItem(this, site)));
}
}
Create an AzureAccountTreeItemBase
that provides the subscriptions you just implemented. It must implement at least createSubscriptionTreeItem
:
export class AzureAccountTreeItem extends AzureAccountTreeItemBase {
public createSubscriptionTreeItem(root: ISubscriptionContext): SubscriptionTreeItemBase {
return new SubscriptionTreeItem(this, root);
}
}
Finally, set up the tree in your extension's activate()
method. Instantiate an AzureAccountTreeItem
and add it to context.subscriptions
since it's a disposable. Then instantiate an AzExtTreeDataProvider
, passing in your root tree item and the loadMoreCommandId
(which maps the 'Load More...' node to the command registered by your extension).
const azureAccountTreeItem = new AzureAccountTreeItem();
context.subscriptions.push(azureAccountTreeItem);
const treeDataProvider = new AzExtTreeDataProvider(azureAccountTreeItem, "appService.loadMore");
context.subscriptions.push(vscode.window.createTreeView("azureAppService", { treeDataProvider }));
FAQs
Common Azure utils for developing Azure extensions for VS Code
The npm package @microsoft/vscode-azext-azureutils receives a total of 1,728 weekly downloads. As such, @microsoft/vscode-azext-azureutils popularity was classified as popular.
We found that @microsoft/vscode-azext-azureutils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 11 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.