Azure Event Hubs is a Big Data streaming platform and event ingestion service that can receive and process millions of events per second. An Event Hubs namespace provides a unique scoping container, in which you create one or more event hubs. We will use REST API to create namespace using POSTMAN.


  • Create Azure Service Principal
  • Create Resource Group
  • Create request in POSTMAN

1. Create Azure Service Principal using Azure CLI. Login to and invoke cloud shell

2. Create an Azure service principal “sp_for_creating_eventhubnamespace“.

az ad sp create-for-rbac --name "sp_for_creating_eventhubnamespace" --role contributor

The appId and tenant keys appear in the output of az ad sp create-for-rbac and are used in service principal authentication. Record their values, but they can be retrieved at any point with az ad sp list.

3. Create Resource Group where Storage account will be created

az group create --location westus --name rg_for_eventhub


4. Open POSTMAN and Import a collection


5. Download the collection and environment json file from


6. After importing the files in POSTMAN, it will appear like below




7. Update the values for variables in environment –

client_id – This is the value of appId from the service principal creation output above.

client_secret – This is the value of password from the service principal creation output above.

tenantid – This is the value of tenantId from the service principal creation output above.

resource – The default value is for managing Azure resources.(

subscriptionId – You can get this with this Azure CLI command az account show --query id

resourceGroupName – This is the value of name from the resource group creation output above.

eventhubNamespace – Add the event hubs namespace name which you want to create.

grant_type – client_credentials

access_token – You do not need to set this.


8. Now create a GET request to get Auth bearer access token. This request will receive bearer token. Using below script in Tests, you can set the token value to “access_token” environment variable.

var data = JSON.parse(responseBody);
postman.setEnvironmentVariable("access_token", data.access_token);


9. Now you can run other REST API calls.


Checkout this –