Skip to content

Commit

Permalink
Adapt EG to arm template (Azure#19262)
Browse files Browse the repository at this point in the history
* arm template

* cloud event domain name

* name domain

* storage

* Revert "storage"

This reverts commit 5e75e1b.

* Update sdk/eventgrid/azure-eventgrid/samples/publish_samples/publish_cloud_events_to_domain_topic_sample.py
  • Loading branch information
Rakshith Bhyravabhotla authored Jun 23, 2021
1 parent fb5f472 commit 185b636
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
1) DOMAIN_ACCESS_KEY - The access key of your eventgrid account.
2) DOMAIN_TOPIC_HOSTNAME - The topic hostname. Typically it exists in the format
"https://<YOUR-TOPIC-NAME>.<REGION-NAME>.eventgrid.azure.net/api/events".
3) DOMAIN_NAME - the name of the topic
"""
import sys
import os
Expand All @@ -27,7 +26,6 @@

domain_key = os.environ["DOMAIN_ACCESS_KEY"]
domain_endpoint = os.environ["DOMAIN_TOPIC_HOSTNAME"]
domain_name = os.environ["DOMAIN_NAME"]


# authenticate client
Expand All @@ -46,7 +44,7 @@ def publish_event():
sample_members = sample(services, k=randint(1, 4)) # select random subset of team members
event = CloudEvent(
type="Azure.Sdk.Demo",
source=domain_name,
source='/demo/domain_name',
data={"team": sample_members}
)
event_list.append(event)
Expand Down
127 changes: 127 additions & 0 deletions sdk/eventgrid/test-resources.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"baseName": {
"type": "String"
}
},
"variables": {
"apiVersion": "2020-04-01-preview",
"eventGridTopicName": "[concat(parameters('baseName'), 'topic')]",
"eventGridDomainName": "[concat(parameters('baseName'), 'domain')]",
"cloudeventTopicName": "[concat(parameters('baseName'), 'cloudevent-topic')]",
"customeventTopicName": "[concat(parameters('baseName'), 'customevent-topic')]",
"cloudeventDomainName": "[concat(parameters('baseName'), 'cloudevent-domain')]"
},
"resources": [
{
"type": "Microsoft.EventGrid/topics",
"apiVersion": "[variables('apiVersion')]",
"name": "[variables('eventGridTopicName')]",
"location": "[resourceGroup().location]"
},
{
"name": "[variables('eventGridDomainName')]",
"type": "Microsoft.EventGrid/domains",
"apiVersion": "[variables('apiVersion')]",
"location": "[resourceGroup().location]",
"properties": {}
},
{
"type": "Microsoft.EventGrid/topics",
"apiVersion": "[variables('apiVersion')]",
"name": "[variables('cloudeventTopicName')]",
"location": "[resourceGroup().location]",
"properties": {
"inputSchema": "CloudEventSchemaV1_0"
}
},
{
"name": "[variables('cloudeventDomainName')]",
"type": "Microsoft.EventGrid/domains",
"apiVersion": "[variables('apiVersion')]",
"location": "[resourceGroup().location]",
"properties": {
"inputSchema": "CloudEventSchemaV1_0"
}
},
{
"type": "Microsoft.EventGrid/topics",
"apiVersion": "[variables('apiVersion')]",
"name": "[variables('customeventTopicName')]",
"location": "[resourceGroup().location]",
"properties": {
"inputSchema": "CustomEventSchema",
"inputSchemaMapping": {
"inputSchemaMappingType": "Json",
"properties": {
"dataVersion": {
"defaultValue": "default",
"sourceField": "TestVersion"
},
"eventTime": {
"sourceField": "TestEventTime"
},
"eventType": {
"defaultValue": "default",
"sourceField": "TestEventType"
},
"id": {
"sourceField": "TestID"
},
"subject": {
"defaultValue": "default",
"sourceField": "TestSubject"
},
"topic": {
"sourceField": "TestTopic"
}
}
}
}
}
],
"outputs": {
"EG_TOPIC_HOSTNAME": {
"type": "string",
"value": "[reference(variables('eventGridTopicName')).endpoint]"
},
"EG_ACCESS_KEY": {
"type": "string",
"value": "[listKeys(resourceId('Microsoft.EventGrid/topics', variables('eventGridTopicName')), variables('apiVersion')).key1]"
},
"EG_DOMAIN_TOPIC_HOSTNAME": {
"type": "string",
"value": "[reference(variables('eventGridDomainName')).endpoint]"
},
"EG_DOMAIN_ACCESS_KEY": {
"type": "string",
"value": "[listKeys(resourceId('Microsoft.EventGrid/domains', variables('eventGridDomainName')), variables('apiVersion')).key1]"
},
"CLOUD_TOPIC_HOSTNAME": {
"type": "string",
"value": "[reference(variables('cloudeventTopicName')).endpoint]"
},
"CLOUD_ACCESS_KEY": {
"type": "string",
"value": "[listKeys(resourceId('Microsoft.EventGrid/topics', variables('cloudeventTopicName')), variables('apiVersion')).key1]"
},
"DOMAIN_TOPIC_HOSTNAME": {
"type": "string",
"value": "[reference(variables('cloudeventDomainName')).endpoint]"
},
"DOMAIN_ACCESS_KEY": {
"type": "string",
"value": "[listKeys(resourceId('Microsoft.EventGrid/domains', variables('cloudeventDomainName')), variables('apiVersion')).key1]"
},
"CUSTOM_SCHEMA_TOPIC_HOSTNAME": {
"type": "string",
"value": "[reference(variables('customeventTopicName')).endpoint]"
},
"CUSTOM_SCHEMA_ACCESS_KEY": {
"type": "string",
"value": "[listKeys(resourceId('Microsoft.EventGrid/topics', variables('customeventTopicName')), variables('apiVersion')).key1]"
}
}
}
12 changes: 1 addition & 11 deletions sdk/eventgrid/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ stages:
- template: ../../eng/pipelines/templates/stages/archetype-sdk-tests.yml
parameters:
ServiceDirectory: eventgrid
DeployArmTemplate: true
BuildTargetingString: azure-eventgrid*
MatrixReplace:
- TestSamples=.*/true
Expand All @@ -13,16 +14,5 @@ stages:
AZURE_TENANT_ID: $(aad-azure-sdk-test-tenant-id)
AZURE_CLIENT_ID: $(aad-azure-sdk-test-client-id)
AZURE_CLIENT_SECRET: $(aad-azure-sdk-test-client-secret)
EG_ACCESS_KEY: $(python-sdk-test-eg-access-key)
EG_TOPIC_HOSTNAME: $(python-sdk-test-eg-topic-hostname)
CLOUD_ACCESS_KEY: $(python-sdk-test-eg-cloud-access-key)
CLOUD_TOPIC_HOSTNAME: $(python-sdk-test-eg-cloud-topic-hostname)
DOMAIN_ACCESS_KEY: $(python-sdk-test-eg-domain-access-key)
DOMAIN_TOPIC_HOSTNAME: $(python-sdk-test-eg-domain-topic-hostname)
EG_DOMAIN_ACCESS_KEY: $(python-sdk-test-domain-access-key-eg)
EG_DOMAIN_TOPIC_HOSTNAME: $(python-sdk-test-domain-topic-hostname-eg)
EVENTGRID_SAS: $(python-sdk-test-eg-sas)
DOMAIN_NAME: $(python-sdk-test-eg-domain-name)
STORAGE_QUEUE_NAME: $(python-storage-queue-name)
CUSTOM_SCHEMA_ACCESS_KEY: $(python-sdk-test-eg-custom-schema-access-key)
CUSTOM_SCHEMA_TOPIC_HOSTNAME: $(python-sdk-test-custom-schema-topic-hostname)

0 comments on commit 185b636

Please sign in to comment.