Can't create event schema using bicep file

Yang Woody 20 Reputation points
2024-12-08T20:56:36.6133333+00:00
There is no API to create schema for a schema group. 

The expected code as following,

resource schema 'Microsoft.EventHub/namespaces/schemagroups/schemas@2024-05-01-preview' = {
  parent: schemaGroup
  name: schemaName
  properties: {
    serialization: serialization
    compatibility: compatibility
    schemaType: 'Json'
    schemaContent: '''
    {
      "$id": "https://abc.com/Order2.schema.json",
      "$schema": "http://json-schema.org/draft-07/schema#",
      "title": "Order10",
      "type": "object",
      "properties": {
        "orderId": {
          "type": "string"
        },
        "orderDate": {
          "type": "string",
          "format": "date-time"
        },
        "customerName": {
          "type": "string"
        },
        "items": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "itemId": {
                "type": "string"
              },
              "quantity": {
                "type": "integer"
              },
              "price": {
                "type": "number"
              }
            },
            "required": ["itemId", "quantity", "price"]
          }
        }
      },
      "required": ["orderId", "orderDate", "customerName", "items"]
    }
    '''
  }
}
Azure Event Hubs
Azure Event Hubs
An Azure real-time data ingestion service.
663 questions
{count} votes

Accepted answer
  1. Smaran Thoomu 18,710 Reputation points Microsoft Vendor
    2024-12-09T10:27:34.7366667+00:00

    Hi @Yang Woody

    Welcome to Microsoft Q&A platform and thanks for posting your query here.

    Currently, it is not possible to create schemas for a schema group directly using a Bicep file because Azure does not expose an API to manage schemas programmatically via ARM/Bicep.

    As an alternative:

    1. Use Azure SDKs (like Python, .NET, or Java) or Azure CLI to create and register schemas in your schema group.
    2. You can also manage schemas manually via the Azure Portal by navigating to your Event Hub namespace and adding schemas under Schema Groups.

    If your workflow requires automation, combining Bicep for infrastructure deployment and an SDK/CLI for schema management is a practical solution.

    For more details, you can refer to:

    Hope this helps. Do let us know if you any further queries.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.