[Event Grid] Migrate to Bicep (#30862)
And update API versions. Live tests run: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=4072835&view=results
This commit is contained in:
Родитель
3335c5eb34
Коммит
73281f24fb
|
@ -0,0 +1,141 @@
|
|||
param baseName string = resourceGroup().name
|
||||
param location string = resourceGroup().location
|
||||
param testApplicationOid string
|
||||
|
||||
var eventGridTopicName = '${baseName}-eg'
|
||||
var cloudEventTopicName = '${baseName}-ce'
|
||||
var customEventTopicName = '${baseName}-cus'
|
||||
var serviceBusNamespaceName = '${baseName}-ns'
|
||||
var egNamespaceName = '${baseName}-egns'
|
||||
var serviceBusQueueName = '${baseName}-queue'
|
||||
var dataSenderRoleDefinitionId = 'd5a91429-5739-47e2-a06b-3470a27159e7'
|
||||
var dataContributorRoleDefinitionId = '1d8c3fe3-8864-474b-8749-01e3783e8157'
|
||||
var sbApiVersion = '2022-10-01-preview'
|
||||
|
||||
// Create Event Grid Topic with EventGridSchema
|
||||
resource eventGridTopic 'Microsoft.EventGrid/topics@2024-06-01-preview' = {
|
||||
name: eventGridTopicName
|
||||
location: location
|
||||
properties: {
|
||||
inputSchema: 'EventGridSchema'
|
||||
publicNetworkAccess: 'Enabled'
|
||||
}
|
||||
}
|
||||
|
||||
// Create Event Grid Topic with CloudEventSchema
|
||||
resource cloudEventTopic 'Microsoft.EventGrid/topics@2024-06-01-preview' = {
|
||||
name: cloudEventTopicName
|
||||
location: location
|
||||
properties: {
|
||||
inputSchema: 'CloudEventSchemaV1_0'
|
||||
publicNetworkAccess: 'Enabled'
|
||||
}
|
||||
}
|
||||
|
||||
// Create Event Grid Topic with CustomEventSchema
|
||||
resource customEventTopic 'Microsoft.EventGrid/topics@2024-06-01-preview' = {
|
||||
name: customEventTopicName
|
||||
location: location
|
||||
properties: {
|
||||
inputSchema: 'CustomEventSchema'
|
||||
inputSchemaMapping: {
|
||||
properties: {
|
||||
id: {}
|
||||
topic: {}
|
||||
eventTime: {}
|
||||
eventType: {
|
||||
sourceField: 'typ'
|
||||
}
|
||||
subject: {
|
||||
sourceField: 'sub'
|
||||
}
|
||||
dataVersion: {
|
||||
sourceField: 'ver'
|
||||
}
|
||||
}
|
||||
inputSchemaMappingType: 'Json'
|
||||
}
|
||||
publicNetworkAccess: 'Enabled'
|
||||
}
|
||||
}
|
||||
|
||||
// Create Service Bus Namespace with a Queue
|
||||
resource serviceBusNamespace 'Microsoft.ServiceBus/namespaces@2022-10-01-preview' = {
|
||||
name: serviceBusNamespaceName
|
||||
location: location
|
||||
sku: {
|
||||
name: 'Basic'
|
||||
}
|
||||
}
|
||||
|
||||
resource serviceBusQueue 'Microsoft.ServiceBus/namespaces/queues@2022-10-01-preview' = {
|
||||
name: serviceBusQueueName
|
||||
parent: serviceBusNamespace
|
||||
}
|
||||
|
||||
// Assign Data Sender Role
|
||||
resource dataSenderRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
|
||||
name: guid(resourceGroup().id, baseName, eventGridTopicName, 'DataSender')
|
||||
properties: {
|
||||
roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', dataSenderRoleDefinitionId)
|
||||
principalId: testApplicationOid
|
||||
}
|
||||
}
|
||||
|
||||
// Assign Data Contributor Role
|
||||
resource dataContributorRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
|
||||
name: guid(resourceGroup().id, baseName, eventGridTopicName, 'DataContributor')
|
||||
properties: {
|
||||
roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', dataContributorRoleDefinitionId)
|
||||
principalId: testApplicationOid
|
||||
}
|
||||
}
|
||||
|
||||
// Create Event Grid Namespace
|
||||
resource egNamespace 'Microsoft.EventGrid/namespaces@2024-06-01-preview' = {
|
||||
name: egNamespaceName
|
||||
location: location
|
||||
sku: {
|
||||
name: 'Standard'
|
||||
capacity: 1
|
||||
}
|
||||
}
|
||||
|
||||
// Create Event Grid Namespace Topic
|
||||
resource egNamespaceTopic 'Microsoft.EventGrid/namespaces/topics@2024-06-01-preview' = {
|
||||
name: 'testtopic1'
|
||||
parent: egNamespace
|
||||
properties: {
|
||||
publisherType: 'Custom'
|
||||
inputSchema: 'CloudEventSchemaV1_0'
|
||||
eventRetentionInDays: 1
|
||||
}
|
||||
}
|
||||
|
||||
// Create Event Grid Namespace Topic Subscription
|
||||
resource egNamespaceTopicSubscription 'Microsoft.EventGrid/namespaces/topics/eventSubscriptions@2024-06-01-preview' = {
|
||||
name: 'testsubscription1'
|
||||
parent: egNamespaceTopic
|
||||
properties: {
|
||||
deliveryConfiguration: {
|
||||
deliveryMode: 'Queue'
|
||||
queue: {
|
||||
receiveLockDurationInSeconds: 60
|
||||
maxDeliveryCount: 10
|
||||
eventTimeToLive: 'P1D'
|
||||
}
|
||||
}
|
||||
eventDeliverySchema: 'CloudEventSchemaV1_0'
|
||||
filtersConfiguration: {
|
||||
includedEventTypes: []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Outputs
|
||||
output EVENT_GRID_EVENT_GRID_SCHEMA_ENDPOINT string = eventGridTopic.properties.endpoint
|
||||
output EVENT_GRID_CLOUD_EVENT_SCHEMA_ENDPOINT string = cloudEventTopic.properties.endpoint
|
||||
output EVENT_GRID_CUSTOM_SCHEMA_ENDPOINT string = customEventTopic.properties.endpoint
|
||||
output SERVICE_BUS_CONNECTION_STRING string = listKeys(resourceId('Microsoft.ServiceBus/namespaces/AuthorizationRules', serviceBusNamespaceName, 'RootManageSharedAccessKey'), sbApiVersion).primaryConnectionString
|
||||
output SERVICE_BUS_QUEUE_NAME string = serviceBusQueueName
|
||||
output EVENT_GRID_NAMESPACES_ENDPOINT string = egNamespace.properties.topicsConfiguration.hostname
|
|
@ -1,197 +0,0 @@
|
|||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"baseName": {
|
||||
"type": "string",
|
||||
"defaultValue": "[resourceGroup().name]",
|
||||
"metadata": {
|
||||
"description": "The base resource name."
|
||||
}
|
||||
},
|
||||
"location": {
|
||||
"type": "string",
|
||||
"defaultValue": "[resourceGroup().location]",
|
||||
"metadata": {
|
||||
"description": "The location of the resource. By default, this is the same as the resource group."
|
||||
}
|
||||
},
|
||||
"testApplicationOid": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "The client OID to grant access to test resources."
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"eventGridTopicName": "[concat(parameters('baseName'), '-eg')]",
|
||||
"cloudEventTopicName": "[concat(parameters('baseName'), '-ce')]",
|
||||
"customEventTopicName": "[concat(parameters('baseName'), '-cus')]",
|
||||
"serviceBusNamespaceName": "[concat(parameters('baseName'), '-ns')]",
|
||||
"egNamespaceName": "[concat(parameters('baseName'), '-egns')]",
|
||||
"serviceBusQueueName": "[concat(parameters('baseName'), '-queue')]",
|
||||
"dataSenderRoleDefinitionId": "d5a91429-5739-47e2-a06b-3470a27159e7",
|
||||
"dataContributorRoleDefinitionId": "1d8c3fe3-8864-474b-8749-01e3783e8157"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.EventGrid/topics",
|
||||
"apiVersion": "2020-06-01",
|
||||
"name": "[variables('eventGridTopicName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"properties": {
|
||||
"inputSchema": "EventGridSchema",
|
||||
"publicNetworkAccess": "Enabled"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.EventGrid/topics",
|
||||
"apiVersion": "2020-06-01",
|
||||
"name": "[variables('cloudEventTopicName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"properties": {
|
||||
"inputSchema": "CloudEventSchemaV1_0",
|
||||
"publicNetworkAccess": "Enabled"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.EventGrid/topics",
|
||||
"apiVersion": "2020-06-01",
|
||||
"name": "[variables('customEventTopicName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"properties": {
|
||||
"inputSchema": "CustomEventSchema",
|
||||
"inputSchemaMapping": {
|
||||
"properties": {
|
||||
"id": {},
|
||||
"topic": {},
|
||||
"eventTime": {},
|
||||
"eventType": {
|
||||
"sourceField": "typ"
|
||||
},
|
||||
"subject": {
|
||||
"sourceField": "sub"
|
||||
},
|
||||
"dataVersion": {
|
||||
"sourceField": "ver"
|
||||
}
|
||||
},
|
||||
"inputSchemaMappingType": "Json"
|
||||
},
|
||||
"publicNetworkAccess": "Enabled"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.ServiceBus/namespaces",
|
||||
"apiVersion": "2017-04-01",
|
||||
"name": "[variables('serviceBusNamespaceName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"sku": {
|
||||
"name": "Basic"
|
||||
},
|
||||
"properties": {},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Queues",
|
||||
"apiVersion": "2017-04-01",
|
||||
"name": "[variables('serviceBusQueueName')]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.ServiceBus/namespaces', variables('serviceBusNamespaceName'))]"
|
||||
],
|
||||
"properties": {}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Authorization/roleAssignments",
|
||||
"apiVersion": "2022-04-01",
|
||||
"name": "[guid(resourceGroup().id, parameters('baseName'), variables('eventGridTopicName'), 'DataSender')]",
|
||||
"properties": {
|
||||
"roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('dataSenderRoleDefinitionId'))]",
|
||||
"principalId": "[parameters('testApplicationOid')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Authorization/roleAssignments",
|
||||
"apiVersion": "2022-04-01",
|
||||
"name": "[guid(resourceGroup().id, parameters('baseName'), variables('eventGridTopicName'), 'DataContributor')]",
|
||||
"properties": {
|
||||
"roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('dataContributorRoleDefinitionId'))]",
|
||||
"principalId": "[parameters('testApplicationOid')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.EventGrid/namespaces",
|
||||
"apiVersion": "2024-06-01-preview",
|
||||
"name": "[variables('egNamespaceName')]",
|
||||
"location": "eastus",
|
||||
"sku": {
|
||||
"name": "Standard",
|
||||
"capacity": 1
|
||||
},
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.EventGrid/namespaces/topics",
|
||||
"apiVersion": "2024-06-01-preview",
|
||||
"name": "[concat(variables('egNamespaceName'), '/testtopic1')]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.EventGrid/namespaces', variables('egNamespaceName'))]"
|
||||
],
|
||||
"properties": {
|
||||
"publisherType": "Custom",
|
||||
"inputSchema": "CloudEventSchemaV1_0",
|
||||
"eventRetentionInDays": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.EventGrid/namespaces/topics/eventSubscriptions",
|
||||
"apiVersion": "2024-06-01-preview",
|
||||
"name": "[concat(variables('egNamespaceName'), '/testtopic1/testsubscription1')]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.EventGrid/namespaces/topics', variables('egNamespaceName'), 'testtopic1')]",
|
||||
"[resourceId('Microsoft.EventGrid/namespaces', variables('egNamespaceName'))]"
|
||||
],
|
||||
"properties": {
|
||||
"deliveryConfiguration": {
|
||||
"deliveryMode": "Queue",
|
||||
"queue": {
|
||||
"receiveLockDurationInSeconds": 60,
|
||||
"maxDeliveryCount": 10,
|
||||
"eventTimeToLive": "P1D"
|
||||
}
|
||||
},
|
||||
"eventDeliverySchema": "CloudEventSchemaV1_0",
|
||||
"filtersConfiguration": {
|
||||
"includedEventTypes": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"outputs": {
|
||||
"EVENT_GRID_EVENT_GRID_SCHEMA_ENDPOINT": {
|
||||
"type": "string",
|
||||
"value": "[reference(variables('eventGridTopicName')).endpoint]"
|
||||
},
|
||||
"EVENT_GRID_CLOUD_EVENT_SCHEMA_ENDPOINT": {
|
||||
"type": "string",
|
||||
"value": "[reference(variables('cloudEventTopicName')).endpoint]"
|
||||
},
|
||||
"EVENT_GRID_CUSTOM_SCHEMA_ENDPOINT": {
|
||||
"type": "string",
|
||||
"value": "[reference(variables('customEventTopicName')).endpoint]"
|
||||
},
|
||||
"SERVICE_BUS_CONNECTION_STRING": {
|
||||
"type": "string",
|
||||
"value": "[listKeys(resourceId('Microsoft.ServiceBus/namespaces/AuthorizationRules',variables('serviceBusNamespaceName'),'RootManageSharedAccessKey'),'2017-04-01').primaryConnectionString]"
|
||||
},
|
||||
"SERVICE_BUS_QUEUE_NAME": {
|
||||
"type": "string",
|
||||
"value": "[variables('serviceBusQueueName')]"
|
||||
},
|
||||
"EVENT_GRID_NAMESPACES_ENDPOINT": {
|
||||
"type": "string",
|
||||
"value": "[concat('https://', reference(variables('egNamespaceName')).topicsConfiguration.hostname)]"
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче