The Azure Developer CLI (azd) has a brand new function referred to as extensions that empowers builders to customise their workflow with azd. For those who’re a developer constructing on Azure, perhaps you have already got a “want record” of CLI capabilities. If that’s the case, you would possibly have the ability to create an extension for them. This put up explores what azd extensions are, their key options, real-world use circumstances, and learn how to use extensions from our registry or create a personal registry. By the tip, you’ll know the way azd extensions can improve your Azure improvement workflow, learn how to apply them in your initiatives, and even construct an extension.
What are azd extensions?
The Azure Developer CLI (azd) extensions are modular additions that reach the azd performance past the built-in instructions and combine seamlessly with the azd instructions and performance. Primarily, an extension is a plugin that may introduce new CLI instructions, permitting you to tailor azd to your particular wants and situations. This implies you possibly can add new capabilities, automate repetitive duties, and even combine third-party or Azure providers straight from the CLI interface.
Extensions carry developer instruments nearer to azd’s core workflow, enabling a extra custom-made and highly effective developer expertise. Extensions could be found and utilized by putting in an extension from the registry. The extensions enable builders to customise their setting, automate advanced processes, and add new capabilities particular to their initiatives. It’d deal with frequent developer ache factors in idiomatic methods or particular concerns to an engineering group’s processes and necessities–with out altering the core of azd. Suppose: sooner deployments, higher debugging, and extra environment friendly administration of cloud sources.
azd extensions are presently launched as an alpha function. This implies it’s essential to allow the extension function earlier than you need to use it. It additionally signifies that the function is early in its lifecycle (so count on speedy enhancements and potential modifications). To decide in to extensions, use the configuration flag in azd:
azd config set alpha.extensions on
Enabling this flag activates extension administration in your azd setting. As soon as enabled, azd offers a set of instructions below the azd extension
namespace to handle extensions (for instance, to record, set up, or take away extensions).
Key options of azd extensions
The extension framework comes with a number of essential options:
- New customized instructions – An extension can introduce its personal CLI instructions or subcommands in azd. An extension would possibly add a brand new top-level command like
azd demo
orazd ai
with its personal set of subcommands. This function permits packaging advanced operations or workflows behind handy instructions. And azd now helps nested command namespaces for extensions, so extension authors can arrange instructions hierarchically. For instance,azd ai setup
,azd ai begin
, and so forth. - Modularity and isolation – Extensions are separate modules, which implies you solely set up what you want. They don’t bloat the core CLI; as an alternative, you decide in to the capabilities related to your mission. For those who not want an extension, you possibly can take away it cleanly. This modular design retains azd lean whereas providing you with flexibility.
- Automated workflows – Extensions can encapsulate automation. For example, they’ll immediate customers for enter, execute a sequence of steps, or pay attention for sure occasions within the CLI course of. The
demo extension
showcases this function by including instructions that reveal interactive prompts and occasion dealing with (extra on workflows within the quickstart). This functionality means which you can construct on high of present azd options to create custom-made multi-step processes. For instance, working assessments and establishing environments to the azd useful resource provisioning move. - Integration with exterior providers – One of many highly effective options of azd extensions is the power to combine exterior instruments or cloud providers with azd. As a result of an extension has entry to azd’s context and may name exterior APIs or scripts, you could possibly create an extension that interacts with Azure providers (past what azd core helps) and even with third-party providers. This would possibly imply to combine with GitHub, Azure DevOps, or your customized inner programs straight from azd. The repo docs have extra element on how extensions assist combine with different providers so you possibly can set off or manipulate exterior sources as a part of your CLI workflow.
- Extension supply registries – As talked about, azd makes use of extension sources to distribute extensions. The official registry is the default, however you possibly can add your personal feeds when you’ve got personal extensions. For instance, an organization may preserve an inner record of azd extensions (maybe for proprietary workflows) and distribute them by way of a personal URL that staff members add with
azd extension supply add
. This design borrows from ideas that builders would possibly acknowledge from package deal managers (like including an npm registry or a NuGet feed). The azd staff curates the official feed, and there’s additionally a “dev” feed for preview extensions the place experimental concepts dwell (with the caveat that these extensions aren’t signed or absolutely supported but). You may decide in to “dev” through the use ofazd extension supply add -n dev -t url -l "https://aka.ms/azd/extensions/registry/dev"
. - Lifecycle administration by way of CLI – As soon as extensions are enabled, all the things from discovering new extensions to maintaining them up to date is dealt with by CLI instructions. This implies you don’t must manually obtain plugins or run separate installers. You get a seamless expertise. For instance, working
azd extension set up microsoft.azd.demo
fetches the extension from the registry and make its instructions accessible instantly. Equally,azd extension improve --all
updates all of your put in extensions when new variations can be found. This reduces upkeep overhead.
The objective of azd extensions is to will let you adapt the CLI to your wants, scale back guide effort, and combine the instruments and providers that matter to you straight into your Azure improvement workflow.
How extensions are delivered?
Azure Developer CLI extensions are delivered by extension sources, that are primarily registries or feeds of extensions. By default, azd comes preconfigured with the official extension registry. That is just like how package deal managers like NuGet or npm have public feeds. You may as well add different extension sources (for instance, a personal registry URL or an area file supply) to put in customized or in-house extensions.
There’s an elective “dev” extension registry for experimental extensions (supposed for inner testing) that customers can decide into. Every extension supply adheres to a selected manifest schema, however azd handles the main points. The extensions system is designed to be open and versatile with the intention to fetch extensions from official Microsoft feeds or your personal group’s feed as wanted.
As soon as extension help is enabled and sources are configured, you possibly can set up extensions. We stroll by a concrete instance, however at a excessive stage, managing extensions is simple. You may record accessible extensions, set up or uninstall them, and improve them utilizing acquainted CLI instructions. For instance:
azd extension record
– lists accessible extensions (--installed
reveals what you may have put in)azd extension set up
– installs a specified extension by titleazd extension improve
– updates an put in extension to a more moderen model (use--all
to replace all the things)azd extension uninstall
– removes an extension you not want
As a result of this technique is in alpha, the extensions instructions are listed below an ‘Extensions’ part of azd’s assist menu, separated from the secure core instructions. This separation makes it clear which elements of azd are experimental.
In abstract, azd extensions present a plugin mechanism to inject customized performance into the azd CLI, giving builders the flexibleness to adapt the instrument to evolve mission and staff necessities.
Utilizing the azd demo extension
A hands-on demo is among the greatest methods to see a brand new function in motion. So, let’s stroll by an instance utilizing the azd demo extension. By making an attempt out this demo extension, you get a really feel for the extension set up course of and learn how to use extension-provided instructions.
1. Conditions
Guarantee you may have the newest model of azd put in. The extension instructions aren’t accessible in variations earlier than 1.17.0.
Optionally, you would possibly wish to initialize an azd mission to make use of with the extension. The demo extension could be run within the context of any azd mission. For a fast begin, you possibly can create a pattern mission utilizing the “Hey azd” template. Navigate to an empty listing and run:
azd init -t hello-azd
This command units up a easy starter mission so that you can experiment with, however you need to use any present azd mission when you’ve got one. The demo extension doesn’t require a selected mission sort.
2. Allow extension help
Make sure you enabled the extensions function in azd (it is a one-time arrange).
azd config set alpha.extensions on
3. Set up the demo extension
Use the azd extension set up command so as to add the extension from the official registry:
azd extension set up microsoft.azd.demo
4. Confirm the extension is put in
You may examine that the extension put in appropriately by itemizing your put in extensions:
azd extension record --installed
This shows a listing of extensions presently added. You must see microsoft.azd.demo
within the output, indicating the demo extension is able to use.
5. Use the extension to discover new instructions
With the demo extension put in, check out its instructions. The extension provides a brand new top-level command to azd named demo. To see what it presents, run:
azd demo
This menu tells us that the extension added a number of subcommands below the azd demo
namespace.
azd demo model
– For those who run this command, it prints the model of the demo extension software.azd demo context
– This command outputs the context of your present azd mission and setting. It demonstrates that the extension can entry your azd mission’s state, such because the template you initialized, what setting is energetic, and so forth., and show it within the terminal output. This may very well be helpful for extensions that must know what you’re engaged on.azd demo colours
– For those who do that command, it prints a desk of ASCII colours within the terminal. It’s a enjoyable instance of how an extension can produce formatted output. Not Azure-specific, but it surely demonstrates that the extension can management console output in inventive methods.azd demo immediate
– This command is essentially the most attention-grabbing. It begins an interactive workflow in your terminal. The extension asks a sequence of questions. For instance, ‘Which Azure providers do you utilize most with azd?’ and presents a listing of choices (Container Apps, Capabilities, Static Internet Apps, and so forth.) in a checkbox-style menu. You may sort to filter the record and choose one or a number of choices. This demonstrates the extension’s capacity to immediate the consumer and deal with enter. After you choose and hit Enter, it would proceed with different prompts together with sure/no questions and different record choices. Consider this sample as constructing an interactive CLI wizard into azd by way of an extension that may very well be utilized in actual extensions to configure providers, collect consumer preferences, or verify actions in a guided means.azd demo pay attention
– This command begins the extension and listens for occasions. On this mode, it listens for sure occasions or triggers from azd. Within the demo, it reveals that extensions can hook into azd’s occasion pipeline (for instance, lifecycle occasions likeinfrastructure provisioned
ordeployment accomplished
) and carry out actions when these happen. Nonetheless, it isn’t supposed to be referred to as straight from customers and extension builders ought to make these instructionshidden
to keep away from confusion.
Experiment with these instructions in your setting. Bear in mind, that is only a demonstration extension, so whereas these instructions don’t change precise sources, they illustrate the mechanics. This extension is utilizing the extension framework API to combine into azd, parse your enter, and show output. For a developer curious about constructing their very own extension, the demo extension’s code serves as a reference implementation of key patterns (studying azd context, prompting consumer, and so forth.).
6. Uninstall the extension (elective)
To see learn how to take away an extension, let’s take away the demo extension. Run:
azd extension uninstall microsoft.azd.demo
This takes the extension out of your azd CLI context and removes the azd demo instructions. You may all the time reinstall it later if wanted.
That’s it! You put in an azd extension and tried its instructions. The method for different extensions is identical: allow extensions (as soon as), then set up the extension you need by title, and use the brand new instructions it offers.
Hopefully this demo extension illustrated how approachable it’s to increase azd’s performance. Subsequent, let’s take a look at actual use circumstances and situations the place such extensions could be beneficial.
Use circumstances and situations for azd extensions
Listed below are some sensible examples and situations the place azd extensions may also help builders in numerous methods.
Combine AI and machine studying providers
One thrilling space for extensions is simplifying AI/ML workflows in Azure. Think about you wish to incorporate AI into your app. An extension may present an azd ai
set of instructions to do that. The truth is, the azd staff has been prototyping an “AI extension” that guides builders by establishing AI sources and integrating them. For instance, a prototype extension presents a command azd ai setup
that launches a guided expertise to configure the required Azure AI providers and even enables you to incorporate your personal customized information into an AI mannequin. This type of extension can automate the steps to provision an Azure AI Service, deploy fashions, and so forth. behind an interactive CLI guided move. No must manually navigate the Azure portal for each setting or write advanced scripts, simply reply a couple of prompts and let the extension do the heavy lifting.
Customized DevOps and pipeline duties
Many groups have DevOps processes that contain numerous scripts and instructions. With extensions, a few of these could be rolled into azd. For instance, you would possibly create an extension that runs a collection of high quality checks (linting, safety scans, and so forth.) tailor-made to your mission. Whereas azd itself already has azd pipeline config for CI/CD, an extension may go additional to combine with exterior programs or cowl situations azd doesn’t natively deal with. One may envision an extension that interacts with GitHub or Azure DevOps REST APIs to work with azd boards create-workitem
(to file a problem or job in GitHub or Azure Boards) or an azd gh
extension that creates GitHub repos or manages labels. The profit is encapsulating these dev lifecycle duties in the identical CLI you utilize for deployment.
Enhanced useful resource administration
Azure is huge, and azd focuses on the core developer workflow (init, up, deploy, monitor). However maybe you need customized useful resource administration duties accessible. Extensions would possibly fill in gaps like managing quotas, cleansing up sources, or toggling settings. For example, as a part of AI integration, the staff mentioned extension instructions to examine Azure AI mannequin availability and quotas. A specialised extension may present instructions to record utilization quotas of sure Azure providers or change between completely different pricing tiers shortly. One other instance may very well be an extension to bulk-delete sources created by an azd template (one thing past azd down
like cleansing up log analytics or different side-resources that azd core won’t absolutely tear down).
Staff or domain-specific extensions
Contemplate an information science staff versus an internet front-end staff and the way their wants differ. An information science staff would possibly construct an extension for azd that provides instructions to deal with information operations, equivalent to triggering an information pipeline or working a machine studying experiment in Azure Machine Studying. An internet front-end staff would possibly construct an extension that interfaces with a headless CMS or a CDN for his or her static content material. Area-specific extensions can encapsulate the instruments and processes of that area. The hot button is that they combine these steps into the general azd workflow in order that deploying the app and managing its associated duties are performed in a single place. Groups engaged on Azure IoT, for instance, may create an extension for IoT hub administration or system provisioning. Groups constructing on Azure Kubernetes Service (AKS) may have an extension to simplify sure kubectl/helm steps as a part of app deployment.
Third-party integrations
Not all developer instruments are Microsoft Azure. You would possibly use providers like Stripe (for funds) or SendGrid (for e-mail) or any variety of APIs. In case your Azure software must arrange or coordinate with these integrations, an azd extension may very well be written to deal with that integration step. For example, an extension would possibly add a command azd sendgrid arrange
to configure the service as a part of your Key Vault utilized in your app, or azd stripe webhooks
to routinely register your deployed app’s endpoints as Stripe webhooks. These examples are hypothetical, however they reveal that extensions may function glue between Azure deployments and exterior programs.
Internal-loop tooling
Some extensions might not even speak to Azure. They could simply make a developer’s inner-loop simpler. For instance, an extension may combine a file generator, so you could possibly do one thing like azd generate unit-test --for
and it creates a check file stub in keeping with your mission’s conventions. Or an extension may wrap docker instructions to run an area improvement container for you if that’s a part of your workflow, equivalent to azd devcontainer up
. Consider any command or script you would like azd had – that’s a candidate for an extension.
It’s value noting that the Azure Developer CLI staff is already engaged on a number of extensions in these areas. We have now a number of extensions in progress to carry extra developer instruments into azd. The AI extension is certainly one of them to allow AI situations. One other is the developer extension that helps builders construct their very own extensions. Sooner or later because the ecosystem grows, we may even see contributions from the group and third-parties addressing area of interest use circumstances by way of extensions.
When you’ve got a selected situation the place a customized command would save time or implement consistency, that’s a fantastic alternative for an extension. They improve the Azure improvement expertise by integrating all the things you want into one move, lowering context switches and guide steps. From provisioning AI providers, to automating mission arrange, to integrating with third-party APIs, the probabilities are broad. The result’s a extra streamlined developer workflow that stays targeted inside Azure Developer CLI.
Construct an extension with an extension
That’s proper. We have now an extension that guides the method of constructing an extension.
1. Set up the extension
# Set up the azd developer extension
azd extension set up microsoft.azd.extensions
As soon as you put in the extension, you see a affirmation and examples within the terminal output.
2. Initialize a brand new extension mission
# Initialize a brand new extension mission
azd x init
Comply with the prompts in your terminal. The namespace is your high stage command. On this instance, I chosen check
because the namespace, so the instructions comply with this namespace, equivalent to azd check [command]
.
Your output ought to look one thing like this after making all your choices.
3. Lastly, check out the brand new extension mission
# Run your new azd extension command
# azd [command] -h
Now you may have an extension. You must construct out the performance of the extension, however contemplate this the on-ramp. And, from right here you can begin constructing.
The right way to contribute
The Azure Developer CLI (azd) is an open-source mission hosted on GitHub. Which means not solely are you able to view the supply code, however you can too contribute to it. Listed below are methods to contribute:
- Construct your personal extension for the registry: (quickly!) since this function is in alpha we aren’t but permitting customers to contribute on to the official azd extension registry, however we do have plans to open this up. This would be the most direct option to contribute to the ecosystem. Contact us if you wish to publish an early extension in our beta launch.
- Contribute to the CLI: when you’ve got concepts to enhance the extension framework (or any a part of azd), you possibly can open points or pull requests on the GitHub repo. The repo has a CONTRIBUTING information and makes use of discussions and points to handle suggestions. As a result of azd is open supply, it means the barrier to recommend modifications is decrease and you may straight have interaction with the code or file a problem for the staff.
- Take part in discussions: azd has dialogue threads for brand new options. By taking part and sharing your wants, you not directly contribute by shaping the priorities. If many builders ask for a sure extension or have a typical ache level, the staff can reply to that.
- Documentation and samples: one other means to assist is to contribute to the docs or examples. The documentation we referenced has a GitHub repository. For those who spot a problem or wish to add an instance (say, a tutorial on constructing an extension), you could possibly submit modifications there. Equally, sharing pattern code for extensions or running a blog about your personal extension expertise may also help develop the data base for everybody.
We are able to’t wait to see what you construct
The azd extensions open up a brand new world of prospects for cloud and AI builders. They create flexibility and customization to your fingertips, permitting you to adapt Azure’s developer tooling to your actual wants. We constructed this extension framework as a result of we dwell in a cloud-first, and more and more AI-first, world the place most initiatives are constructed for cloud and AI infrastructure. We wished to present builders the power to maneuver sooner when constructing cloud and AI options of their software as a result of time-to-market is essential.
For those who’re a developer constructing on Azure, now is a good time to experiment with azd extensions. Check out the demo extension to get a really feel for it, after which take into consideration these “want record” CLI capabilities you need. You would possibly have the ability to create an extension for them. And as you do, share your suggestions with the Azure Developer CLI staff. Collectively, we will form this function into one thing really empowering for all Azure builders.