| 1 |
@description('Name of the eventhub namespace') |
| 2 |
param eventHubNamespaceName string |
| 3 |
|
| 4 |
@description('Name of the eventhub name') |
| 5 |
param eventHubName string |
| 6 |
|
| 7 |
@description('The service principal') |
| 8 |
param principalId string |
| 9 |
|
| 10 |
// Create an event hub namespace |
| 11 |
resource eventHubNamespace 'Microsoft.EventHub/namespaces@2021-01-01-preview' = { |
| 12 |
name: eventHubNamespaceName |
| 13 |
location: resourceGroup().location |
| 14 |
sku: { |
| 15 |
name: 'Standard' |
| 16 |
tier: 'Standard' |
| 17 |
capacity: 1 |
| 18 |
} |
| 19 |
properties: { |
| 20 |
zoneRedundant: true |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
// Create an event hub inside the namespace |
| 25 |
resource eventHub 'Microsoft.EventHub/namespaces/eventhubs@2021-01-01-preview' = { |
| 26 |
parent: eventHubNamespace |
| 27 |
name: eventHubName |
| 28 |
properties: { |
| 29 |
messageRetentionInDays: 7 |
| 30 |
partitionCount: 1 |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
// give Azure Pipelines Service Principal permissions against the event hub |
| 35 |
|
| 36 |
var roleDefinitionAzureEventHubsDataOwner = subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'f526a384-b230-433a-b45c-95f59c4a2dec') |
| 37 |
|
| 38 |
resource integrationTestEventHubReceiverNamespaceRoleAssignment 'Microsoft.Authorization/roleAssignments@2018-01-01-preview' = { |
| 39 |
name: guid(principalId, eventHub.id, roleDefinitionAzureEventHubsDataOwner) |
| 40 |
scope: eventHubNamespace |
| 41 |
properties: { |
| 42 |
roleDefinitionId: roleDefinitionAzureEventHubsDataOwner |
| 43 |
principalId: principalId |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
// From https://dev.azure.com/johnnyreilly/blog-demos/_git/permissioning-azure-pipelines-bicep-role-assignments?path=/infra/main.bicep |