Batch with unique relationships - neo4j

Using Neo4J 2.0.0-M5, I'm trying to create my database using a batch, as is explained at :
http://docs.neo4j.org/chunked/milestone/rest-api-batch-ops.html
What I want to do is inserting nodes and relationships with the "get_or_create" mode, so that I can run the batch multiple times without creating redundant nodes and relationships.
Creating unique nodes can be done with /index/node/indexname?uniqueness=get_or_create, for example :
POST /db/data/batch [
{"method":"POST","to":"/index/node/concept?uniqueness=get_or_create","id":0,"body":{"key":"nom", "value":"organisation", "properties": {"nom":"organisation"}}},
{"method":"POST","to":"/index/node/concept?uniqueness=get_or_create","id":1,"body":{"key":"nom", "value":"établissement", "properties": {"nom":"établissement"}}}
]
However, I don't find how I can create a unique relationship between the two indexed nodes?
I want to state that there is a "est" relationship between "établissement" and "organisation". If I try with :
POST /db/data/batch [
{"method":"POST","to":"/index/node/concept?uniqueness=get_or_create","id":0,"body":{"key":"nom", "value":"organisation", "properties": {"nom":"organisation"}}},
{"method":"POST","to":"/index/node/concept?uniqueness=get_or_create","id":1,"body":{"key":"nom", "value":"établissement", "properties": {"nom":"établissement"}}},
{"method":"POST","to":"{1}/relationships","body":{"to":"{0}","type":"est"}},
{"method":"POST","to":"/index/relationship/my_rels?uniqueness=get_or_create","body":{"key":"nom","value":"est","uri":"{1}"}}
]
I get :
==> 500 Internal Server Error
==> {
==> "message" : "",
==> "exception" : "BatchOperationFailedException",
==> "fullname" : "org.neo4j.server.rest.domain.BatchOperationFailedException",
==> "stacktrace" : ["org.neo4j.server.rest.batch.NonStreamingBatchOperations.invoke(NonStreamingBatchOperations.java:63)", "org.neo4j.server.rest.batch.BatchOperations.performRequest(BatchOperations.java:188)", "org.neo4j.server.rest.batch.BatchOperations.parseAndPerform(BatchOperations.java:159)", "org.neo4j.server.rest.batch.NonStreamingBatchOperations.performBatchJobs(NonStreamingBatchOperations.java:48)", "org.neo4j.server.rest.web.BatchOperationService.batchProcess(BatchOperationService.java:123)", "org.neo4j.server.rest.web.BatchOperationService.performBatchOperations(BatchOperationService.java:73)", "java.lang.reflect.Method.invoke(Method.java:606)", "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:132)", "org.neo4j.server.rest.security.SecurityFilter.doFilter(SecurityFilter.java:112)" ]
==> }
I'm stuck with this problem, so any advice would be really appreciated. Thank you!
Grégoire
EDIT: the problem seems to come from a bug that prevents unique nodes to be referenced from within a batch :
https://github.com/neo4j/neo4j/issues/84

The workaround (as stated in the github bug you mentioned) is to use Cypher.
Example using Batch and Cypher:
[
{"method":"POST","to":"/index/node/concept?uniqueness=get_or_create","id":0,"body":{"key":"nom", "value":"organisation", "properties": {"nom":"organisation"}}},
{"method":"POST","to":"/index/node/concept?uniqueness=get_or_create","id":1,"body":{"key":"nom", "value":"établissement", "properties": {"nom":"établissement"}}},
{
"method": "POST",
"to": "/cypher",
"id": 1,
"body": {
"query" : "START a=node:concept(nom={aVal}), b=node:concept(nom={bVal}) CREATE b-[r:est]->a RETURN a, b, r",
"params" : {
"aVal" : "établissement",
"bVal" : "organisation"
}
}
}
]
Output:
[{
"id": 0,
"location": "http://localhost:7474/db/data/index/node/concept/nom/organisation/18688",
"body": {
"extensions": {},
"paged_traverse": "http://localhost:7474/db/data/node/18688/paged/traverse/{returnType}{?pageSize,leaseTime}",
"outgoing_relationships": "http://localhost:7474/db/data/node/18688/relationships/out",
"all_typed_relationships": "http://localhost:7474/db/data/node/18688/relationships/all/{-list|&|types}",
"traverse": "http://localhost:7474/db/data/node/18688/traverse/{returnType}",
"property": "http://localhost:7474/db/data/node/18688/properties/{key}",
"all_relationships": "http://localhost:7474/db/data/node/18688/relationships/all",
"self": "http://localhost:7474/db/data/node/18688",
"outgoing_typed_relationships": "http://localhost:7474/db/data/node/18688/relationships/out/{-list|&|types}",
"properties": "http://localhost:7474/db/data/node/18688/properties",
"incoming_relationships": "http://localhost:7474/db/data/node/18688/relationships/in",
"incoming_typed_relationships": "http://localhost:7474/db/data/node/18688/relationships/in/{-list|&|types}",
"create_relationship": "http://localhost:7474/db/data/node/18688/relationships",
"data": {
"nom": "organisation"
},
"indexed": "http://localhost:7474/db/data/index/node/concept/nom/organisation/18688"
},
"from": "/index/node/concept?uniqueness=get_or_create"
}, {
"id": 1,
"location": "http://localhost:7474/db/data/index/node/concept/nom/%EF%BF%BDtablissement/18689",
"body": {
"extensions": {},
"paged_traverse": "http://localhost:7474/db/data/node/18689/paged/traverse/{returnType}{?pageSize,leaseTime}",
"outgoing_relationships": "http://localhost:7474/db/data/node/18689/relationships/out",
"all_typed_relationships": "http://localhost:7474/db/data/node/18689/relationships/all/{-list|&|types}",
"traverse": "http://localhost:7474/db/data/node/18689/traverse/{returnType}",
"property": "http://localhost:7474/db/data/node/18689/properties/{key}",
"all_relationships": "http://localhost:7474/db/data/node/18689/relationships/all",
"self": "http://localhost:7474/db/data/node/18689",
"outgoing_typed_relationships": "http://localhost:7474/db/data/node/18689/relationships/out/{-list|&|types}",
"properties": "http://localhost:7474/db/data/node/18689/properties",
"incoming_relationships": "http://localhost:7474/db/data/node/18689/relationships/in",
"incoming_typed_relationships": "http://localhost:7474/db/data/node/18689/relationships/in/{-list|&|types}",
"create_relationship": "http://localhost:7474/db/data/node/18689/relationships",
"data": {
"nom": "�tablissement"
},
"indexed": "http://localhost:7474/db/data/index/node/concept/nom/%EF%BF%BDtablissement/18689"
},
"from": "/index/node/concept?uniqueness=get_or_create"
}, {
"id": 1,
"body": {
"columns": ["a", "b", "r"],
"data": [
[{
"paged_traverse": "http://localhost:7474/db/data/node/18689/paged/traverse/{returnType}{?pageSize,leaseTime}",
"outgoing_relationships": "http://localhost:7474/db/data/node/18689/relationships/out",
"data": {
"nom": "�tablissement"
},
"traverse": "http://localhost:7474/db/data/node/18689/traverse/{returnType}",
"all_typed_relationships": "http://localhost:7474/db/data/node/18689/relationships/all/{-list|&|types}",
"self": "http://localhost:7474/db/data/node/18689",
"all_relationships": "http://localhost:7474/db/data/node/18689/relationships/all",
"property": "http://localhost:7474/db/data/node/18689/properties/{key}",
"properties": "http://localhost:7474/db/data/node/18689/properties",
"outgoing_typed_relationships": "http://localhost:7474/db/data/node/18689/relationships/out/{-list|&|types}",
"incoming_relationships": "http://localhost:7474/db/data/node/18689/relationships/in",
"incoming_typed_relationships": "http://localhost:7474/db/data/node/18689/relationships/in/{-list|&|types}",
"extensions": {},
"create_relationship": "http://localhost:7474/db/data/node/18689/relationships"
}, {
"paged_traverse": "http://localhost:7474/db/data/node/18688/paged/traverse/{returnType}{?pageSize,leaseTime}",
"outgoing_relationships": "http://localhost:7474/db/data/node/18688/relationships/out",
"data": {
"nom": "organisation"
},
"traverse": "http://localhost:7474/db/data/node/18688/traverse/{returnType}",
"all_typed_relationships": "http://localhost:7474/db/data/node/18688/relationships/all/{-list|&|types}",
"self": "http://localhost:7474/db/data/node/18688",
"all_relationships": "http://localhost:7474/db/data/node/18688/relationships/all",
"property": "http://localhost:7474/db/data/node/18688/properties/{key}",
"properties": "http://localhost:7474/db/data/node/18688/properties",
"outgoing_typed_relationships": "http://localhost:7474/db/data/node/18688/relationships/out/{-list|&|types}",
"incoming_relationships": "http://localhost:7474/db/data/node/18688/relationships/in",
"incoming_typed_relationships": "http://localhost:7474/db/data/node/18688/relationships/in/{-list|&|types}",
"extensions": {},
"create_relationship": "http://localhost:7474/db/data/node/18688/relationships"
}, {
"start": "http://localhost:7474/db/data/node/18688",
"data": {},
"self": "http://localhost:7474/db/data/relationship/44187",
"property": "http://localhost:7474/db/data/relationship/44187/properties/{key}",
"properties": "http://localhost:7474/db/data/relationship/44187/properties",
"type": "est",
"extensions": {},
"end": "http://localhost:7474/db/data/node/18689"
}]
]
},
"from": "/cypher"
}]

Related

Data creation Error creating a kafka message to producer - Expected start-union. Got VALUE_STRING [duplicate]

Unable to Error creating a kafka message to producer - Expected start-union. Got VALUE_STRING
{
"namespace": "de.morris.audit",
"type": "record",
"name": "AuditDataChangemorris",
"fields": [
{"name": "employeeID", "type": "string"},
{"name": "employeeNumber", "type": ["null", "string"], "default": null},
{"name": "serialNumbers", "type": [ "null", {"type": "array", "items": "string"}]},
{"name": "correlationId", "type": "string"},
{"name": "timestamp", "type": "long", "logicalType": "timestamp-millis"},
{"name": "employmentscreening","type":{"type": "enum", "name": "employmentscreening", "symbols": ["NO","YES"]}},
{"name": "vouchercodes","type": ["null",
{
"type": "array",
"items": {
"name": "Vouchercodes",
"type": "record",
"fields": [
{"name": "voucherName","type": ["null","string"], "default": null},
{"name": "authocode","type": ["null","string"], "default": null}
]
}
}], "default": null}
]
}
when i was trying to create a sample data in json format based on the above avsc for kafka consumer i am getting the below error upon testing
{
"employeeID": "qtete46524",
"employeeNumber": {
"string": "custnumber9813"
},
"serialNumbers": {
"type": "array",
"items": ["363536623","5846373733"]
},
"correlationId": "corr-656532443",
"timestamp": 1476538955719,
"employmentscreening": "NO",
"vouchercodes": [
{
"voucherName": "skygo",
"authocode": "A238472ASD"
}
]
}
getting the below error when i got when i ran the dataflow job in gcp
Error message from worker: java.lang.RuntimeException: java.io.IOException: Insert failed: [{"errors":[{"debugInfo":"","location":"serialnumbers","message":"Array specified for non-repeated field: serialnumbers.","reason":"invalid"}],"index":0}]**
how to create correct sample data based on the above schema ?
Read the spec
The value of a union is encoded in JSON as follows:
if its type is null, then it is encoded as a JSON null;
otherwise it is encoded as a JSON object with one name/value pair whose name is the type’s name and whose value is the recursively encoded value
So, here's the data it expects.
{
"employeeID": "qtete46524",
"employeeNumber": {
"string": "custnumber9813"
},
"serialNumbers": {"array": [
"serialNumbers3521"
]},
"correlationId": "corr-656532443",
"timestamp": 1476538955719,
"employmentscreening": "NO",
"vouchercodes": {"array": [
{
"voucherName": {"string": "skygo"},
"authocode": {"string": "A238472ASD"}
}
]}
}
With this schema
{
"namespace": "de.morris.audit",
"type": "record",
"name": "AuditDataChangemorris",
"fields": [
{
"name": "employeeID",
"type": "string"
},
{
"name": "employeeNumber",
"type": [
"null",
"string"
],
"default": null
},
{
"name": "serialNumbers",
"type": [
"null",
{
"type": "array",
"items": "string"
}
]
},
{
"name": "correlationId",
"type": "string"
},
{
"name": "timestamp",
"type": {
"type": "long",
"logicalType": "timestamp-millis"
}
},
{
"name": "employmentscreening",
"type": {
"type": "enum",
"name": "employmentscreening",
"symbols": [
"NO",
"YES"
]
}
},
{
"name": "vouchercodes",
"type": [
"null",
{
"type": "array",
"items": {
"name": "Vouchercodes",
"type": "record",
"fields": [
{
"name": "voucherName",
"type": [
"null",
"string"
],
"default": null
},
{
"name": "authocode",
"type": [
"null",
"string"
],
"default": null
}
]
}
}
],
"default": null
}
]
}
Here's an example of producing and consuming to Kafka
$ jq -rc < /tmp/data.json | kafka-avro-console-producer --topic foobar --property value.schema="$(jq -rc < /tmp/data.avsc)" --bootstrap-server localhost:9092 --sync
$ kafka-avro-console-consumer --topic foobar --from-beginning --bootstrap-server localhost:9092 | jq
{
"employeeID": "qtete46524",
"employeeNumber": {
"string": "custnumber9813"
},
"serialNumbers": {
"array": [
"serialNumbers3521"
]
},
"correlationId": "corr-656532443",
"timestamp": 1476538955719,
"employmentscreening": "NO",
"vouchercodes": {
"array": [
{
"voucherName": {
"string": "skygo"
},
"authocode": {
"string": "A238472ASD"
}
}
]
}
}
^CProcessed a total of 1 messages

Twilio IVR Speech Recognition

I'm new to developing IVR with twilio studio so I started with the basic template and even that's not working.
This is the log:
LOG
Split Based On...
DETAIL
Input evaluated to 'Sales.' from '{{widgets.gather_input.SpeechResult}}'
Transitioning to 'say_play_1' because 'Sales.' did not match any expression
The split is set to "Equal to" sales which then connects the call to a number. It's obviously recognizing the correct speech input but still not working. Any ideas?
{
"description": "IVR",
"states": [
{
"name": "Trigger",
"type": "trigger",
"transitions": [
{
"event": "incomingMessage"
},
{
"next": "gather_input",
"event": "incomingCall"
},
{
"event": "incomingRequest"
}
],
"properties": {
"offset": {
"x": 250,
"y": 50
}
}
},
{
"name": "gather_input",
"type": "gather-input-on-call",
"transitions": [
{
"next": "split_key_press",
"event": "keypress"
},
{
"next": "split_speech_result",
"event": "speech"
},
{
"event": "timeout"
}
],
"properties": {
"voice": "alice",
"speech_timeout": "auto",
"offset": {
"x": 290,
"y": 250
},
"loop": 1,
"hints": "support,sales",
"finish_on_key": "",
"say": "Hello, how can we direct your call? Press 1 for sales, or say sales. To reach support, press 2 or say support.",
"language": "en",
"stop_gather": false,
"gather_language": "en-US",
"profanity_filter": "false",
"timeout": 5
}
},
{
"name": "split_key_press",
"type": "split-based-on",
"transitions": [
{
"event": "noMatch"
},
{
"next": "connect_call_to_sales",
"event": "match",
"conditions": [
{
"friendly_name": "1",
"arguments": [
"{{widgets.gather_input.Digits}}"
],
"type": "equal_to",
"value": "1"
}
]
},
{
"next": "connect_call_to_support",
"event": "match",
"conditions": [
{
"friendly_name": "2",
"arguments": [
"{{widgets.gather_input.Digits}}"
],
"type": "equal_to",
"value": "2"
}
]
}
],
"properties": {
"input": "{{widgets.gather_input.Digits}}",
"offset": {
"x": 100,
"y": 510
}
}
},
{
"name": "split_speech_result",
"type": "split-based-on",
"transitions": [
{
"next": "say_play_1",
"event": "noMatch"
},
{
"next": "connect_call_to_sales",
"event": "match",
"conditions": [
{
"friendly_name": "sales",
"arguments": [
"{{widgets.gather_input.SpeechResult}}"
],
"type": "equal_to",
"value": "sales"
}
]
},
{
"next": "connect_call_to_support",
"event": "match",
"conditions": [
{
"friendly_name": "support",
"arguments": [
"{{widgets.gather_input.SpeechResult}}"
],
"type": "equal_to",
"value": "support"
}
]
}
],
"properties": {
"input": "{{widgets.gather_input.SpeechResult}}",
"offset": {
"x": 510,
"y": 510
}
}
},
{
"name": "connect_call_to_sales",
"type": "connect-call-to",
"transitions": [
{
"event": "callCompleted"
}
],
"properties": {
"offset": {
"x": 100,
"y": 750
},
"caller_id": "{{contact.channel.address}}",
"noun": "number",
"to": "12222222",
"timeout": 30
}
},
{
"name": "connect_call_to_support",
"type": "connect-call-to",
"transitions": [
{
"event": "callCompleted"
}
],
"properties": {
"offset": {
"x": 520,
"y": 750
},
"caller_id": "{{contact.channel.address}}",
"noun": "number",
"to": "12222222",
"timeout": 30
}
},
{
"name": "say_play_1",
"type": "say-play",
"transitions": [
{
"next": "gather_input",
"event": "audioComplete"
}
],
"properties": {
"offset": {
"x": 710,
"y": 200
},
"loop": 1,
"say": "not valid choice."
}
}
],
"initial_state": "Trigger",
"flags": {
"allow_concurrent_calls": true
}
}
Twilio developer evangelist here.
That is weird behaviour, mainly because the log says "evaluated to 'Sales.'". Split widgets conditions are not case-sensitive and should trim leading and following white-space. For some reason this appears to have a capital "S" and a full-stop.
I would suggest a couple of things. Firstly, raise a ticket with Twilio support to look into why the condition didn't match correctly.
Then, try some of the other conditions. When I generate a new IVR template in Studio, the conditions use "Matches any of" instead of "Equal to". You might also try "Contains".
So, experiment with the ways you can match the operators, but get support involved to drill down into why it didn't work in the first place.
The period is needed after the word for some reason...I just put both, for example:
"1, 1., Uno, Uno., Una, Una., Uno, Uno., Español, Español., Español, Español., Español, Español."

AWS CDK - trying to add Input Transformer using class aws_cdk.aws_events.RuleTargetInputProperties

As the title mentions, I'm trying to replicate a Input Transformer using RuleTargetInputProperties but i can't seem to find any examples or get the correct format to input.
The template i'm trying to replicate is the following:
InputTemplate: |
{
"sourceVersion": <sourceVersion>,
"artifactsOverride": {"type": "NO_ARTIFACTS"},
"environmentVariablesOverride": [
{
"name": "PULL_REQUEST_ID",
"value": <pullRequestId>,
"type": "PLAINTEXT"
},
{
"name": "REPOSITORY_NAME",
"value": <repositoryName>,
"type": "PLAINTEXT"
},
{
"name": "SOURCE_COMMIT",
"value": <sourceCommit>,
"type": "PLAINTEXT"
},
{
"name": "DESTINATION_COMMIT",
"value": <destinationCommit>,
"type": "PLAINTEXT"
},
{
"name" : "REVISION_ID",
"value": <revisionId>,
"type": "PLAINTEXT"
}
]
}
InputPathsMap:
sourceVersion: "$.detail.sourceCommit"
pullRequestId: "$.detail.pullRequestId"
repositoryName: "$.detail.repositoryNames[0]"
sourceCommit: "$.detail.sourceCommit"
destinationCommit: "$.detail.destinationCommit"
revisionId: "$.detail.revisionId"
I've tried with RuleTargetInput, but this doesn't give me the correct template
on_pr_rule = repo.on_pull_request_state_change("PR",
target=targets.CodeBuildProject(project,
dead_letter_queue=dead_letter_queue,
event=events.RuleTargetInput.from_object({
"sourceVersion": events.EventField.from_path("$.detail.sourceCommit"),
"pullRequestId": events.EventField.from_path("$.detail.pullRequestId"),
"repositoryName": events.EventField.from_path("$.detail.repositoryNames[0]"),
"sourceCommit": events.EventField.from_path("$.detail.sourceCommit"),
"destinationCommit": events.EventField.from_path("$.detail.destinationCommit"),
"revisionId": events.EventField.from_path("$.detail.revisionId")
})
)
)
InputTransformer:
InputPathsMap:
detail-sourceCommit: $.detail.sourceCommit
detail-pullRequestId: $.detail.pullRequestId
detail-repositoryNames-0-: $.detail.repositoryNames[0]
detail-destinationCommit: $.detail.destinationCommit
detail-revisionId: $.detail.revisionId
InputTemplate: '{"sourceVersion":<detail-sourceCommit>,"pullRequestId":<detail-pullRequestId>,"repositoryName":<detail-repositoryNames-0->,"sourceCommit":<detail-sourceCommit>,"destinationCommit":<detail-destinationCommit>,"revisionId":<detail-revisionId>}'
Has anyone had any experience with adding a template as such using RuleTargetInputProperties?
From the input, I am guessing you are working on the PR workflow. This is what I ended up with .
_pr_build_events_input = events.RuleTargetInput.from_object({
"sourceVersion": events.EventField.from_path("$.detail.sourceCommit"),
"artifactsOverride": {"type": "NO_ARTIFACTS"},
"environmentVariablesOverride": [
{
"name": 'pullRequestId',
"value": EventField.from_path('$.detail.pullRequestId'),
"type": 'PLAINTEXT',
},
{
"name": 'repositoryName',
"value": EventField.from_path('$.detail.repositoryNames[0]'),
"type": 'PLAINTEXT',
},
{
"name": 'sourceCommit',
"value": EventField.from_path('$.detail.sourceCommit'),
"type": 'PLAINTEXT',
},
{
"name": 'destinationCommit',
"value": EventField.from_path('$.detail.destinationCommit'),
"type": 'PLAINTEXT',
},
{
"name": 'revisionId',
"value": EventField.from_path('$.detail.revisionId'),
"type": 'PLAINTEXT',
},
],
})

ARM Template for Importing Azure Key Vault Certificate in Function App

I have a function app which calls another API with a certificate. This certificate (.pfx) file is already present in the key vault. I am using below ARM template to import the certificate to SSL settings of the function app.
Note: the function app gets deployed fine when I remove section "hostNameSslStates". But after adding it, I get -
"Code": "Conflict",
"Message": "The certificate with thumbprint 'XXXXXXXX' does not match the hostname
'blobcreate-eventgridtrigger-functionapp.azurewebsites.net'."
ARM Template resources section-
`
"resources": [
//StorageAccount
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "[parameters('storageAccounts_name')]",
"location": "[resourceGroup().location]",
"sku": {
"name": "[parameters('storageSKU')]",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
"networkAcls": {
"bypass": "AzureServices",
"virtualNetworkRules": [],
"ipRules": [],
"defaultAction": "Allow"
},
"supportsHttpsTrafficOnly": true,
"encryption": {
"services": {
"file": {
"keyType": "Account",
"enabled": true
},
"blob": {
"keyType": "Account",
"enabled": true
}
},
"keySource": "Microsoft.Storage"
},
"accessTier": "Hot"
}
},
//BlobService
{
"type": "Microsoft.Storage/storageAccounts/blobServices",
"apiVersion": "2019-06-01",
"name": "[variables('blobServiceName')]",
"dependsOn": ["[variables('storageAccountResourceId')]"],
"sku": {
"name": "[parameters('storageSKU')]"//,
// "tier": "Standard"
},
"properties": {
"cors": {
"corsRules": []
},
"deleteRetentionPolicy": {
"enabled": false
}
}
},
//function app with server farm
//cert store access policies update-
{
"type": "Microsoft.KeyVault/vaults",
"name": "testARMTemplateKeyVault",
"apiVersion": "2016-10-01",
"location": "[resourceGroup().location]",
"properties": {
"sku": {
"family": "A",
"name": "standard"
},
"tenantId": "c29678d0-eceb-4df2-a225-79cf795a6b64",
"accessPolicies": [
{
"tenantId": "tenantIdOfSubscription", //obtained from Get-AzTenant
"objectId": "objectid of Microsoft Azure App Service", //obtained from Get-AzADServicePrincipal
"permissions": {
"keys": [
"Get",
"List",
"Update",
"Create",
"Import",
"Delete",
"Recover",
"Backup",
"Restore"
],
"secrets": [
"Get",
"List",
"Set",
"Delete",
"Recover",
"Backup",
"Restore"
],
"certificates": [
"Get",
"List",
"Update",
"Create",
"Import",
"Delete",
"Recover",
"ManageContacts",
"ManageIssuers",
"GetIssuers",
"ListIssuers",
"DeleteIssuers"
],
"storage": []
}
}
],
"enabledForDeployment": false,
"enabledForDiskEncryption": false,
"enabledForTemplateDeployment": true,
"enableSoftDelete": true
}
},
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2018-02-01",
"name": "[variables('azurefunction_hostingPlanName')]",
"location": "[resourceGroup().location]",
"sku": {
"name": "Y1",
"tier": "Dynamic"
},
"properties": {
"name": "[variables('azurefunction_hostingPlanName')]",
"computeMode": "Dynamic"
}
},
{
"type": "Microsoft.Web/certificates",
"name": "testingcert",
"apiVersion": "2016-03-01",
"location": "[resourceGroup().location]",
"properties": {
"keyVaultId": "[resourceId('Microsoft.KeyVault/vaults', 'testARMTemplateKeyVault')]",
"keyVaultSecretName": "testingcert",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('azurefunction_hostingPlanName'))]"
}
},
{
"apiVersion": "2018-11-01",
"type": "Microsoft.Web/sites",
"name": "[parameters('functionAppName')]",
"location": "[resourceGroup().location]",
"kind": "functionapp",
"dependsOn": [
"[variables('azureFunction_serverFarmResourceId')]",
"[variables('storageAccountResourceId')]",
"[resourceId('Microsoft.Web/certificates', 'testingcert')]"
],
"properties": {
"serverFarmId": "[variables('azureFunction_serverFarmResourceId')]",
"siteConfig": {
"appSettings": [
{
"name": "AzureWebJobsStorage",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccounts_name'), ';AccountKey=', listKeys(variables('storageAccountResourceId'),variables('storageAccountApiVersion')).keys[0].value)]"
},
{
"name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccounts_name'), ';AccountKey=', listKeys(variables('storageAccountResourceId'),variables('storageAccountApiVersion')).keys[0].value)]"
},
{
"name": "WEBSITE_CONTENTSHARE",
"value": "[toLower(parameters('functionAppName'))]"
},
{
"name": "FUNCTIONS_EXTENSION_VERSION",
"value": "~2"
},
{
"name": "WEBSITE_NODE_DEFAULT_VERSION",
"value": "~10"
},
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference(resourceId('microsoft.insights/components/', parameters('functionApp_applicationInsightsName')), '2015-05-01').InstrumentationKey]"
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "dotnet"
},
{
"name": "WEBSITE_LOAD_CERTIFICATES",
"value": "required certificate thumprint"
}
]
},
"hostNameSslStates": [
{
"name": "blobcreate-eventgridtrigger-functionapp.azurewebsites.net",//obtained from custom domains flatform features of the function app
"sslState": "SniEnabled",
"thumbprint": "[reference(resourceId('Microsoft.Web/certificates', 'testingcert')).Thumbprint]",
"toUpdate": true
}
]
}
}
]`
add certificates section in template -
{
"type": "Microsoft.Web/certificates",
"name": "[parameters('CertificateName')]",
"apiVersion": "2019-08-01",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Web/serverFarms/', variables('azurefunction_hostingPlanName'))]"
],
"properties": {
"keyVaultId": "[parameters('keyvaultResourceId')]",
"keyVaultSecretName": "[parameters('invoiceApiCertificateKeyVaultSecretName')]",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('azurefunction_hostingPlanName'))]"
}
}
and then add dependsOn for this certificate in the function app-
[resourceId('Microsoft.Web/certificates', parameters('CertificateName'))]
well, the error is quite obvious, you are trying to add a certificate for blobcreate-eventgridtrigger-functionapp.azurewebsites.net but the dns name on the certificate doesnt match that, hence the error. that is probably not the right way to add a certificate unless its going to be used for SSL termination

Creating an avro schema for an array with multiple record types?

I am creating an avro schema for a JSON payload that appear to have an array of multiple objects. I'm not sure exactly how to represent this in the schema. The key in question is content:
{
"id": "channel-id",
"name": "My Channel with a New Title",
"description": "Herpy me derpy merpus herpsum ner berp berps derp ter tee",
"privacyLevel": "<private|org>",
"planId": "some-plan-id",
"owner": "a-user-handle",
"curators": [
"user-handle-1",
"user-handle-2"
],
"members": 5,
"content": [
{
"id": "docker",
"slug": "docker",
"index": 1,
"type": "path"
},
{
"id": "such-linkage",
"slug": "such-linkage",
"index": 2,
"type": "external-link",
"details": {
"url": "http://some-dank-link.com",
"title": "My Dank Link",
"contentType": "External Link",
"level": "Beginner",
"duration": "PT34293H33M9S"
}
},
{
"id": "21f1e812-b10a-40df-8b52-3a1d05fc215c",
"slug": "windows-azure-storage-in-depth",
"index": 3,
"type": "course"
},
{
"id": "7c346c05-6416-42dd-80b2-d5e758de7926",
"slug": "7c346c05-6416-42dd-80b2-d5e758de7926",
"index": 4,
"type": "project"
}
],
"imageUrls": ["https://url/to/an/image", "https://url/to/another/image"],
"analyticsEnabled": true,
"orgDiscoverable": false,
"createdDate": "2015-12-31T01:23:45+00:00",
"archiveDate": "2015-12-31T01:23:45+00:00",
"messagePublishedAt": "2015-12-31T01:23:45+00:00"
}
If you are asking if it is possible create an array with different kind of records, it is. Avro support this through union. it would looks like .
{
"name": "myRecord",
"type":"record",
"fields":[
{
"name":"myArrayWithMultiplesTypes",
"type":{
"type": "array",
"items":[
{
"name":"typeOne",
"type":"record",
"fields":[
{"name":"name", "type":"string"}
]
},
{
"name":"typeTwo",
"type":"record",
"fields":[
{"name":"id", "type":"int"}
]
}
]
}
}
]
}
If you already have the records defined previously, then it could look like this:
{
"name": "mulitplePossibleTypes",
"type": [
"null",
{
"type": "array",
"items": [
"com.xyz.kola.cloud.events.itemmanager.Part",
"com.xyz.kola.cloud.events.itemmanager.Document",
"com.xyz.kola.cloud.events.itemmanager.DigitalModel",
"com.xyz.kola.cloud.events.itemmanager.Interface"
]
}
]
},

Resources