|
| 1 | +// Parameters |
| 2 | +@description('Specifies the name prefix.') |
| 3 | +param prefix string = uniqueString(resourceGroup().id) |
| 4 | + |
| 5 | +@description('Specifies the primary location of Azure resources.') |
| 6 | +param location string = resourceGroup().location |
| 7 | + |
| 8 | +@description('Specifies the resource tags.') |
| 9 | +param tags object = {} |
| 10 | + |
| 11 | +@description('Specifies the name of the Event Grid Namespace.') |
| 12 | +param name string = '${prefix}egn' |
| 13 | + |
| 14 | +@description('Specifies the name of the Event Grid Namespace Topic Space.') |
| 15 | +param eventGridNamesapceTopicSpaceName string = 'samples' |
| 16 | + |
| 17 | +@description('Specifies the name of the encoded certificate.') |
| 18 | +param encodedCertificate string |
| 19 | + |
| 20 | +resource eventGridNamesapce 'Microsoft.EventGrid/namespaces@2024-06-01-preview' = { |
| 21 | + name: name |
| 22 | + location: location |
| 23 | + tags: tags |
| 24 | + sku: { |
| 25 | + name: 'Standard' |
| 26 | + capacity: 1 |
| 27 | + } |
| 28 | + identity: { |
| 29 | + type: 'SystemAssigned' |
| 30 | + } |
| 31 | + properties: { |
| 32 | + isZoneRedundant: true |
| 33 | + topicsConfiguration: {} |
| 34 | + topicSpacesConfiguration: { |
| 35 | + state: 'Enabled' |
| 36 | + } |
| 37 | + } |
| 38 | +} |
| 39 | + |
| 40 | +resource eventGridCaCertificate 'Microsoft.EventGrid/namespaces/caCertificates@2024-06-01-preview' = if (encodedCertificate != '') { |
| 41 | + parent: eventGridNamesapce |
| 42 | + name: 'Intermediate01' |
| 43 | + properties: { |
| 44 | + encodedCertificate: encodedCertificate |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | +resource eventGridClient 'Microsoft.EventGrid/namespaces/clients@2024-06-01-preview' = { |
| 49 | + parent: eventGridNamesapce |
| 50 | + name: 'sample_client' |
| 51 | + properties: { |
| 52 | + authenticationName: 'sample_client' |
| 53 | + state: 'Enabled' |
| 54 | + clientCertificateAuthentication: { |
| 55 | + validationScheme: 'SubjectMatchesAuthenticationName' |
| 56 | + } |
| 57 | + attributes: { |
| 58 | + room: '345' |
| 59 | + floor: 12 |
| 60 | + deviceTypes: [ |
| 61 | + 'Fan' |
| 62 | + 'Light' |
| 63 | + ] |
| 64 | + } |
| 65 | + description: 'This is a sample client' |
| 66 | + } |
| 67 | +} |
| 68 | + |
| 69 | +resource eventGridNamesapceTopicSpace 'Microsoft.EventGrid/namespaces/topicSpaces@2024-06-01-preview' = { |
| 70 | + parent: eventGridNamesapce |
| 71 | + name: eventGridNamesapceTopicSpaceName |
| 72 | + properties: { |
| 73 | + description: 'This is a sample topic-space for Event Grid namespace' |
| 74 | + topicTemplates: [ |
| 75 | + 'sample/#' |
| 76 | + ] |
| 77 | + } |
| 78 | +} |
| 79 | + |
| 80 | +resource permissionBindingForPublisher 'Microsoft.EventGrid/namespaces/permissionBindings@2024-06-01-preview' = { |
| 81 | + name: 'samplesPub' |
| 82 | + parent: eventGridNamesapce |
| 83 | + properties: { |
| 84 | + clientGroupName: '$all' |
| 85 | + description: 'A publisher permission binding for the namespace' |
| 86 | + permission: 'Publisher' |
| 87 | + topicSpaceName: eventGridNamesapceTopicSpace.name |
| 88 | + } |
| 89 | +} |
| 90 | + |
| 91 | +resource permissionBindingForSubscriber 'Microsoft.EventGrid/namespaces/permissionBindings@2024-06-01-preview' = { |
| 92 | + name: 'samplesSub' |
| 93 | + parent: eventGridNamesapce |
| 94 | + properties: { |
| 95 | + clientGroupName: '$all' |
| 96 | + description: 'A subscriber permission binding for the namespace' |
| 97 | + permission: 'Subscriber' |
| 98 | + topicSpaceName: eventGridNamesapceTopicSpace.name |
| 99 | + } |
| 100 | +} |
0 commit comments