Create Event Hub resource
You will first need to create an Azure Event Hub namespace to send events to. Create an Event Hub namespace and assign to it a globally unique name. In the namespace you will then create an event hub named telemetry
. You will be connecting to the Event Hub by authenticating with the managed identities you created in earlier labs. You can use the following guidance to implement these changes:
- Quickstart: Create an event hub using Azure CLI.
- Authenticate a managed identity with Azure Active Directory to access Event Hubs Resources.
Step by step guidance
-
On your lab computer, in the Git Bash window, from the Git Bash prompt, run the following command to create an Event Hub namespace. The name you use for your namespace should be globally unique, so adjust it accordingly in case the randomly generated name is already in use.
EVENTHUBS_NAMESPACE=evhns-$APPNAME-$UNIQUEID az eventhubs namespace create \ --resource-group $RESOURCE_GROUP \ --name $EVENTHUBS_NAMESPACE \ --location $LOCATION
-
Next, create an event hub named
telemetry
in the newly created namespace.EVENTHUB_NAME=telemetry az eventhubs eventhub create \ --name $EVENTHUB_NAME \ --resource-group $RESOURCE_GROUP \ --namespace-name $EVENTHUBS_NAMESPACE
-
You will be connecting to the event hub with the identities of the
customers
andvets
microservices you created earlier. You will need to provide these identities access to the event hub.EVENTHUB_ID=$(az eventhubs namespace show --name $EVENTHUBS_NAMESPACE --resource-group $RESOURCE_GROUP --query id -o tsv) az role assignment create --assignee $CUSTOMERS_SERVICE_CID --role 'Azure Event Hubs Data Owner' --scope $EVENTHUB_ID az role assignment create --assignee $VETS_SERVICE_CID --role 'Azure Event Hubs Data Owner' --scope $EVENTHUB_ID