Urara-Blog/node_modules/.pnpm-store/v3/files/a9/5e729973a0d8991c3fe6732c92ceebf7d0422c26e0580cf780615b5fc79ce3b0a3687226fb5aadb7cc9ebfededdd44aba6595db3eb717034aa6f8fe84b353e
2022-08-14 01:14:53 +08:00

47 lines
No EOL
1.4 KiB
Text

@description('Name of the eventhub namespace')
param eventHubNamespaceName string
@description('Name of the eventhub name')
param eventHubName string
@description('The service principal')
param principalId string
// Create an event hub namespace
resource eventHubNamespace 'Microsoft.EventHub/namespaces@2021-01-01-preview' = {
name: eventHubNamespaceName
location: resourceGroup().location
sku: {
name: 'Standard'
tier: 'Standard'
capacity: 1
}
properties: {
zoneRedundant: true
}
}
// Create an event hub inside the namespace
resource eventHub 'Microsoft.EventHub/namespaces/eventhubs@2021-01-01-preview' = {
parent: eventHubNamespace
name: eventHubName
properties: {
messageRetentionInDays: 7
partitionCount: 1
}
}
// give Azure Pipelines Service Principal permissions against the event hub
var roleDefinitionAzureEventHubsDataOwner = subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'f526a384-b230-433a-b45c-95f59c4a2dec')
resource integrationTestEventHubReceiverNamespaceRoleAssignment 'Microsoft.Authorization/roleAssignments@2018-01-01-preview' = {
name: guid(principalId, eventHub.id, roleDefinitionAzureEventHubsDataOwner)
scope: eventHubNamespace
properties: {
roleDefinitionId: roleDefinitionAzureEventHubsDataOwner
principalId: principalId
}
}
// From https://dev.azure.com/johnnyreilly/blog-demos/_git/permissioning-azure-pipelines-bicep-role-assignments?path=/infra/main.bicep