Proto commits in Azure/bicep

These 12 commits are when the Protocol Buffers files have changed:

Commit:d4b28b6
Author:Anthony Martin
Committer:GitHub

Add comments to explain gRPC fields (#18863) Mostly generated using copilot prompt: ``` Copy the comments from https://github.com/Azure/bicep-extensibility/blob/main/docs/vnext/openapi.yaml ```

Commit:9a9b56e
Author:Anthony Martin
Committer:GitHub

[Local Deploy] Support type discovery via gRPC interface (#17665) ## Description 1. Support type discovery via gRPC interface 1. Use mock extension properly in mocks, remove old implementation (`BicepExtensionImpl`) 1. Update end-to-end tests to use new logic 1. Large refactor to avoid extension authors having to deal with JSON serialization/deserialization Preview of these changes in 2 sample repos: * https://github.com/anthony-c-martin/bicep-ext-github/compare/ant/vnext * https://github.com/anthony-c-martin/bicep-ext-local/compare/ant/vnext ## Checklist - [x] I have read and adhere to the [contribution guide](https://github.com/Azure/bicep/blob/main/CONTRIBUTING.md). ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/17665)

The documentation is generated from this commit.

Commit:717b9cc
Author:Anthony Martin
Committer:Anthony Martin

Support type discovery via gRPC interface

The documentation is generated from this commit.

Commit:2a31b6c
Author:Anthony Martin
Committer:Anthony Martin

Support type discovery via gRPC interface

The documentation is generated from this commit.

Commit:d2c6749
Author:Anthony Martin
Committer:Anthony Martin

Support type discovery via gRPC interface

The documentation is generated from this commit.

Commit:cf4d2f1
Author:Samir Banjanovic
Committer:GitHub

Extension Framework Updates (#17616) ## Description This pull request introduces a new framework for building Bicep extensions. The new framework simplifies the process of creating local Bicep extensions by providing a fluent, strongly-typed API that abstracts away the complexity of gRPC communication and resource lifecycle management. ### Key Features 🏗️ Fluent Configuration API • Simple, chainable extension methods for configuring Bicep extensions • Built-in command-line argument parsing with support for Unix sockets, named pipes, and HTTP transport • Automatic gRPC server setup with HTTP/2 protocol configuration 🎯 Strongly-Typed Resource Handling • Generic IResourceHandler<TResource> interface for type-safe resource operations • Automatic JSON deserialization to strongly-typed C# models • Support for both typed and generic resource handlers • Built-in validation and error handling 🔧 Developer Experience Enhancements • Dependency injection integration with ASP.NET Core • Automatic service registration and discovery • Built-in logging and diagnostic tracing • gRPC reflection support in development environments ### Architecture Overview The framework consists of three main components: 1. Host Configuration (WebApplicationBuilderExtensions) - Sets up the gRPC server, command-line parsing, and transport layer 2. Service Registration (IServiceCollectionExtensions) - Configures dependency injection, type system, and resource handlers 3. Request Dispatch (ResourceRequestDispatcher) - Routes gRPC requests to appropriate resource handlers with automatic serialization ### Benefits • 🛡️ Type Safety: Compile-time validation and IntelliSense support reduce runtime errors • ⚡ Productivity: Minimal boilerplate code - focus on business logic rather than infrastructure • 🔍 Maintainability: Clear separation of concerns and standardized patterns • 🧪 Testability: Interface-based design enables easy unit testing and mocking ## Example Usage ```csharp using Bicep.Local.Extension.Host.Extensions; using MyExtension.Handlers; using MyExtension.Models; var builder = WebApplication.CreateBuilder(); // Configure the Bicep extension host with command-line parsing and gRPC setup builder.AddBicepExtensionHost(args); // Register core extension services with type definitions builder.Services.AddBicepExtensionServices( name: "MyCompany.KubernetesExtension", version: "1.0.0", isSingleton: true, typeConfiguration: (typeFactory, config) => { // Define custom configuration schema var stringType = typeFactory.Create(() => new StringType()); config["apiUrl"] = new ObjectTypeProperty( typeFactory.GetReference(stringType), ObjectTypePropertyFlags.Required, "The Kubernetes API server URL"); }); // Register resource handlers for different resource types builder.Services.AddBicepResourceHandler<KubernetesPodHandler>(); builder.Services.AddBicepResourceHandler<KubernetesServiceHandler>(); builder.Services.AddBicepResourceHandler<GenericResourceHandler>(); // Fallback handler var app = builder.Build(); // Map the resource dispatcher to handle gRPC requests app.MapBicepDispatcher(); // Start the extension (handles --describe or runs gRPC server) await app.RunBicepExtensionAsync(); ``` ```c# public class KubernetesPodHandler : IResourceHandler<KubernetesPod> { private readonly IKubernetesClient _client; private readonly ILogger<KubernetesPodHandler> _logger; public KubernetesPodHandler(IKubernetesClient client, ILogger<KubernetesPodHandler> logger) { _client = client; _logger = logger; } public async Task<HandlerResponse> CreateOrUpdate( HandlerRequest<KubernetesPod> request, CancellationToken cancellationToken) { var pod = request.Resource; // Strongly-typed KubernetesPod object // Implement pod creation/update logic var result = await _client.CreateOrUpdatePodAsync(pod, cancellationToken); return HandlerResponse.Success( type: request.Type, properties: result.ToJsonObject(), identifiers: new JsonObject { ["name"] = pod.Name, ["namespace"] = pod.Namespace }, apiVersion: request.ApiVersion); } // Implement Preview, Get, Delete methods... } ``` ## Checklist - [x] I have read and adhere to the [contribution guide](https://github.com/Azure/bicep/blob/main/CONTRIBUTING.md). ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/17616) --------- Co-authored-by: Anthony Martin <38542602+anthony-c-martin@users.noreply.github.com> Co-authored-by: Bicep Automation <bicep@noreply.github.com>

Commit:c196b01
Author:Anthony Martin

Switch to using gRPC

The documentation is generated from this commit.

Commit:9010e2d
Author:Anthony Martin

Avoid aspnet dependency in language server

Commit:e280973
Author:Jorge Cotillo
Committer:GitHub

[LocalDeploy] Migrate to extensibility v2 contract (#14438) # Contributing a Pull Request If you haven't already, read the full [contribution guide](https://github.com/Azure/bicep/blob/main/CONTRIBUTING.md). The guide may have changed since the last time you read it, so please double-check. Once you are done and ready to submit your PR, run through the relevant checklist below. ## Contributing to documentation * [ ] All documentation contributions should be made directly in the [Bicep documentation on Microsoft Docs](https://docs.microsoft.com/azure/azure-resource-manager/bicep/). ## Contributing an example We are integrating the Bicep examples into the [Azure QuickStart Templates](https://github.com/Azure/azure-quickstart-templates/blob/master/1-CONTRIBUTION-GUIDE/README.md). If you'd like to contribute new example `.bicep` files that showcase abilities of the language, please follow [these instructions](https://github.com/Azure/azure-quickstart-templates/blob/master/1-CONTRIBUTION-GUIDE/README.md) to add them directly there. We can still take bug reports and fixes for the existing examples for the time being. * [ ] This is a bug fix for an existing example * [ ] I have resolved all warnings and errors shown by the Bicep VS Code extension * [x] I have checked that all tests are passing by running `dotnet test` * [x] I have consistent casing for all of my identifiers and am using camelCasing unless I have a justification to use another casing style ## Contributing a feature * [ ] I have opened a new issue for the proposal, or commented on an existing one, and ensured that the Bicep maintainers are good with the design of the feature being implemented * [ ] I have included "Fixes #{issue_number}" in the PR description, so GitHub can link to the issue and close it when the PR is merged * [x] I have appropriate test coverage of my new feature ## Contributing a snippet * [ ] I have a snippet that is either a single, generic resource or multi resource that uses [parent-child syntax](https://docs.microsoft.com/azure/azure-resource-manager/bicep/child-resource-name-type) * [ ] I have checked that there is not an equivalent snippet already submitted * [ ] I have used camelCasing unless I have a justification to use another casing style * [ ] I have placeholders values that correspond to their property names (e.g. `dnsPrefix: 'dnsPrefix'`), unless it's a property that MUST be changed or parameterized in order to deploy. In that case, I use 'REQUIRED' e.g. [keyData](./src/Bicep.LangServer/Files/SnippetTemplates/res-aks-cluster.bicep#L26) * [ ] I have my symbolic name as the first tab stop ($1) in the snippet. e.g. [res-aks-cluster.bicep](./src/Bicep.LangServer/Files/SnippetTemplates/res-aks-cluster.bicep) * [ ] I have a resource name property equal to "name" * [ ] If applicable, I have set the `location` property to `location: /*${<id>:location}*/'location'` (not `resourceGroup().location`) where `<id>` is a placeholder id, and added `param location string` to the test's main.bicep file so that the resulting main.combined.bicep file used in the tests compiles without errors * [ ] I have verified that the snippet deploys correctly when used in the context of an actual bicep file e.g. ```bicep resource aksCluster 'Microsoft.ContainerService/managedClusters@2021-03-01' = { name: 'name' ``` ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/14438) --------- Co-authored-by: Anthony Martin <38542602+anthony-c-martin@users.noreply.github.com>

Commit:9064388
Author:Anthony Martin
Committer:Anthony Martin

Convert JSONRPC -> gRPC

Commit:ded2a94
Author:Anthony Martin
Committer:GitHub

Add 'localDeploy' experimental feature, base extension nuget library (#14231) * Add wiring for "localDeploy" experimental feature. The feature doesn't do anything yet as of this PR. * Add "Bicep.Local.Extension" nuget package to contain logic for C# extension authoring. * Add "extension.proto" to defined the contract between client (Bicep) and extension in gRPC. * Support unpacking of provider packages to the local file system to the ~/.bicep cache folder. The full spec is available [here](https://microsoft.sharepoint.com/:w:/t/UniZomb/EVjskctj231Ipua9EVu5e4oBV83O8WsxNpD3InQZevLe2g?e=1CoJeV) - unfortunately only available to Microsoft employees currently. ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/14231)

Commit:acc2144
Author:Anthony Martin

Try to use gRPC