The Azure Schema Registry provides a repository for developers that wish to store, define and enforce schemas in their distributed applications and services.
These samples demonstrate how to use the schema registry to encode and decode events. The samples also show how to use the schema registry with Azure Event Hubs when producing and consuming events.
The following prerequisites are needed to run the samples in this repository:
- Azure Event Hubs namespace: Create an Event Hubs namespace and an event hub
- Schema registry: Create an Azure Event Hubs schema registry
- Role assignments: Included samples use the DefaultAzureCredential for all Azure SDK clients and Azure Function bindings. Your local developer account, application registration(s), and/or Azure Function system-assigned managed identities will all need to be assigned the following roles:
Settings for both the consumer and producer applications are stored in a local App.config
file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="EH_NAMESPACE" value="{event-hubs-namespace-name}.servicebus.windows.net"/>
<add key="EH_NAME" value="{event-hub-name}"/>
<add key="SCHEMA_GROUP" value="{schema-group-name}"/>
<add key="SCHEMA_REGISTRY_URL" value="{event-hubs-namespace-name}.servicebus.windows.net"/>
</appSettings>
</configuration>
To specify the application identity for Azure SDK client credentials, add the following to the <appSettings>
element:
<add key="AZURE_TENANT_ID" value="{azure-tenant-id}"/>
<add key="AZURE_CLIENT_ID" value="{application-client-id}"/>
<add key="AZURE_CLIENT_SECRET" value="{application-client-secret}"/>
Function settings for local.settings.json
when using Managed Identity or local developer account credentials:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"EventHubsConnection__fullyQualifiedNamespace": "{event-hubs-connection-string}.servicebus.windows.net",
"EventHubName": "{event-hub-name}",
"SchemaGroup": "{schema-group-name}",
"SchemaRegistryUrl": "{event-hubs-namespace-name}.servicebus.windows.net",
}
}
To specify the application identity for Azure SDK client and Azure Function bindings credentials, add the following elements to the Values
object:
"EventHubsConnection__tenantId": "{azure-tenant-id}",
"EventHubsConnection__clientId": "{application-client-id}",
"EventHubsConnection__clientSecret": "{application-client-secret}",
"AZURE_TENANT_ID": "{azure-tenant-id}",
"AZURE_CLIENT_ID": "{application-client-id}",
"AZURE_CLIENT_SECRET": "{application-client-secret}"
Functions that run in an isolated process have the same settings except for the worker runtime value:
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"