URL to an icon that appears on the menu item. Relative URLs are resolved using baseUri.
groupId
Determines where this menu item appears in relation to the others.
uri
URI to a page that registers the menu action handler (see below).
registeredObjectId
(Optional) Name of the registered menu action handler. Defaults to the contributor ID.
Learn about all of the places where you can add actions in Extensibility points.
Your HTML page
Your menu action is represented by a JavaScript script embedded in an HTML file. Save the following contents in a file and location that matches the reference to it
in your extension's manifest file.
HTML
<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8"><title>Action Sample</title></head><body><div>
The end user doesn't see the content on this page.
It is only in the background to handle the contributed menu item being selected.
</div></body></html>
Your JavaScript
The script below registers the handler object to handle the action, place it in the head section of the previous HTML page.
We aliased lib to be node_modules/azure-devops-extension-sdk/lib in our sdk-extension.json manifest file.
TypeScript
<script src="lib/SDK.min.js"></script>
<script>
SDK.init();
// Use an IIFE to create an object that satisfies the IContributedMenuSource contract
var menuContributionHandler = (function () {
"use strict";
return {
// This is a callback that gets invoked when a user selects the newly contributed menu item
// The actionContext parameter contains context data surrounding the circumstances of this
// action getting invoked.
execute: function (actionContext) {
alert("Hello, world");
}
};
}());
// Associate the menuContributionHandler object with the "myAction" menu contribution from the manifest.
SDK.register(SDK.getContributionId(), menuContributionHandler);
</script>
Now that you've written your extension, the next steps are to Package, Publish, and Install your extension. You can also check out the
documentation for Testing and Debugging your extension.
Pievienojieties meetup sērijai, lai kopā ar citiem izstrādātājiem un ekspertiem izveidotu mērogojamus AI risinājumus, kuru pamatā ir reālas lietošanas gadījumi.
Learn how to build message extensions that allow users to interact with external services within their flow of work in Microsoft Teams and Microsoft 365 Copilot.