JSON formatting for Terraform API - json

I am trying to create a JSON file that will add env variables to a TFE workspace via API.. I am new to JSON so bear with me.. below is what I am trying to use but I can’t seem to get the brackets or formatting correct.. can someone help me out?
{
"data": {
"type":"vars",
"attributes": {
"key":"ID1",
"value":"xxxxxx",
"description":"",
"category":"terraform",
"hcl":false,
"sensitive":false
}
}
"data": {
"type":"vars",
"attributes": {
"key":"ID2",
"value":"xxxxxx",
"description":"",
"category":"terraform",
"hcl":false,
"sensitive":false
}
}
"data": {
"type":"vars",
"attributes": {
"key":"ID3",
"value":"xxxxxx",
"description":"",
"category":"terraform",
"hcl":false,
"sensitive":true
}
}
"data": {
"type":"vars",
"attributes": {
"key":"ID4",
"value":"xxxxxx",
"description":"",
"category":"terraform",
"hcl":false,
"sensitive":true
}
}
}

The following is a valid JSON payload:
{
"data": [
{
"type": "vars",
"attributes": {
"key": "ID1",
"value": "xxxxxx",
"description": "",
"category": "terraform",
"hcl": false,
"sensitive": false
}
},
{
"type": "vars",
"attributes": {
"key": "ID2",
"value": "xxxxxx",
"description": "",
"category": "terraform",
"hcl": false,
"sensitive": false
}
},
{
"type": "vars",
"attributes": {
"key": "ID3",
"value": "xxxxxx",
"description": "",
"category": "terraform",
"hcl": false,
"sensitive": true
}
},
{
"type": "vars",
"attributes": {
"key": "ID4",
"value": "xxxxxx",
"description": "",
"category": "terraform",
"hcl": false,
"sensitive": true
}
}
]
}

Related

How Should the Json Output Look in Nlog?

I am using nlog json layout and took this from the example
{
"Logging": {
"NLog": {
"IncludeScopes": false,
"ParseMessageTemplates": true,
"CaptureMessageProperties": true
}
},
"NLog": {
"autoreload": true,
"internalLogLevel": "Info",
"internalLogFile": "c:/temp/console-example-internal2.log",
"throwConfigExceptions": true,
"targets": {
"console": {
"type": "Console",
"layout": "${date}|${level:uppercase=true}|${message} ${exception:format=tostring}|${logger}|${all-event-properties}"
},
"file": {
"type": "AsyncWrapper",
"target": {
"wrappedFile": {
"type": "File",
"fileName": "c:/temp/console-example2.log",
"layout": {
"type": "JsonLayout",
"Attributes": [
{ "name": "timestamp", "layout": "${date:format=o}" },
{ "name": "level", "layout": "${level}" },
{ "name": "logger", "layout": "${logger}" },
{ "name": "message", "layout": "${message:raw=true}" },
{ "name": "properties", "encode": false, "layout": { "type": "JsonLayout", "includeallproperties": "true" } }
]
}
}
}
}
},
"rules": [
{
"logger": "*",
"minLevel": "Trace",
"writeTo": "File,Console"
}
]
}
}
https://github.com/NLog/NLog.Extensions.Logging/blob/master/examples/NetCore2/ConsoleExampleJsonConfig/appsettings.json
on this line I saw this { "name": "message", "layout": "${message:raw=true}" } I changed it to false.
when I do this
var test = "Something";
logger.Info("This is what is stored in the variable: {var}", test);
I get
{
"message": This is what is stored in the variable: \"Something\""
}
Why is it in quotes?
When I change raw to "true" I get
{
"message": This is what is stored in the variable: {test}"
}
how do I just get "This is what is stored in the variable: Something"

Card_V2 display issue in Google Chat

I have the following JSON to display Card_V2 for Google Chat, (note: words with "let_" are variables):
{
"cards_v2": [
{
"card": {
"header": {
"title": "Create campaign",
"subtitle": "Please complete the following information",
"imageType": "CIRCLE",
"imageUrl": "let_avatar"
},
"sections": [
{
"widgets": [
{
"textInput": {
"label": "Campaign name",
"type": "SINGLE_LINE",
"name": "nCampaign",
"value": "let_campaign"
}
},
{
"textInput": {
"label": "Campaign subject",
"type": "SINGLE_LINE",
"name": "subject",
"value": "let_subject"
}
},
{
"textInput": {
"label": "User name",
"type": "SINGLE_LINE",
"name": "userName",
"value": "let_userName"
}
},
{
"buttonList": {
"buttons": [
{
"text": "Create campaign",
"color": {
"red": 0.502,
"green": 1,
"blue": 0.733,
"alpha": 1
},
"onClick": {
"action": {
"function": "create",
"parameters": []
}
}
},
{
"text": "Cancel",
"color": {
"red": 0.502,
"green": 1,
"blue": 0.733,
"alpha": 1
},
"onClick": {
"action": {
"function": "cancel",
"parameters": []
}
}
}
]
},
"horizontalAlignment": "CENTER"
}
]
}
]
}
}
]
}
My problem is that the "textInput" screen does not appear, but last week it did. Does anyone have any idea what's going on?
PS: the Card is the return of the onMessage(event) function in Google Apps Script

Troble finding URN of Item from BIM 360 using Autodesk Forge

We have our files in BIM 360 container. We are trying to create the viewer app which consume the BIM360 file and display it in browser, the sample code which available in Forge site for Viewer is working fine in our local environment but we are facing issue with accessing BIM360 urn in same app (we already tried with the 3- legged authentication token too ). Could you please guide us to get the right URN for the file which are stored in BIM360 container? Please find the sample URN (we have converted to base64 while accessing in viewer app)which belongs to the DWG file in BIM360 , kindly let us know whether it is right one or not.
urn:adsk.objects:os.object:wip.dm.prod/7c21a6f0-41c9-42ae-a2b2-4b5741fa4d0c.dwg
urn:adsk.objects:os.object:wip.dm.prod/9ece42b9-c71c-4a27-90bb-87775f370164.dwg
Also please find the item details response json,
{
"jsonapi": {
"version": "1.0"
},
"links": {
"self": {
"href": "https://developer.api.autodesk.com/data/v1/projects/b.56fded29-645c-44b6-9498-29c0f9517fec/items/urn:adsk.wipprod:dm.lineage:1sbrvwIVRJ6J_hnfeVDA2g"
}
},
"data": {
"type": "items",
"id": "urn:adsk.wipprod:dm.lineage:1sbrvwIVRJ6J_hnfeVDA2g",
"attributes": {
"displayName": "bandra ga.dwg",
"createTime": "2021-02-16T11:06:47.0000000Z",
"createUserId": "8DCHNK3XFCM2",
"createUserName": "VBSL System Integrator",
"lastModifiedTime": "2021-02-16T11:06:47.0000000Z",
"lastModifiedUserId": "8DCHNK3XFCM2",
"lastModifiedUserName": "VBSL System Integrator",
"hidden": false,
"reserved": false,
"extension": {
"type": "items:autodesk.bim360:File",
"version": "1.0",
"schema": {
"href": "https://developer.api.autodesk.com/schema/v1/versions/items:autodesk.bim360:File-1.0"
},
"data": {
"sourceFileName": "bandra ga.dwg"
}
}
},
"links": {
"self": {
"href": "https://developer.api.autodesk.com/data/v1/projects/b.56fded29-645c-44b6-9498-29c0f9517fec/items/urn:adsk.wipprod:dm.lineage:1sbrvwIVRJ6J_hnfeVDA2g"
},
"webView": {
"href": "https://docs.b360.autodesk.com/projects/56fded29-645c-44b6-9498-29c0f9517fec/folders/urn%3Aadsk.wipprod%3Afs.folder%3Aco.nPlZOfdwQQiTrkXjS0FVVw/detail/viewer/items/urn%3Aadsk.wipprod%3Adm.lineage%3A1sbrvwIVRJ6J_hnfeVDA2g"
}
},
"relationships": {
"tip": {
"data": {
"type": "versions",
"id": "urn:adsk.wipprod:fs.file:vf.1sbrvwIVRJ6J_hnfeVDA2g?version=1"
},
"links": {
"related": {
"href": "https://developer.api.autodesk.com/data/v1/projects/b.56fded29-645c-44b6-9498-29c0f9517fec/items/urn:adsk.wipprod:dm.lineage:1sbrvwIVRJ6J_hnfeVDA2g/tip"
}
}
},
"versions": {
"links": {
"related": {
"href": "https://developer.api.autodesk.com/data/v1/projects/b.56fded29-645c-44b6-9498-29c0f9517fec/items/urn:adsk.wipprod:dm.lineage:1sbrvwIVRJ6J_hnfeVDA2g/versions"
}
}
},
"parent": {
"data": {
"type": "folders",
"id": "urn:adsk.wipprod:fs.folder:co.nPlZOfdwQQiTrkXjS0FVVw"
},
"links": {
"related": {
"href": "https://developer.api.autodesk.com/data/v1/projects/b.56fded29-645c-44b6-9498-29c0f9517fec/items/urn:adsk.wipprod:dm.lineage:1sbrvwIVRJ6J_hnfeVDA2g/parent"
}
}
},
"refs": {
"links": {
"self": {
"href": "https://developer.api.autodesk.com/data/v1/projects/b.56fded29-645c-44b6-9498-29c0f9517fec/items/urn:adsk.wipprod:dm.lineage:1sbrvwIVRJ6J_hnfeVDA2g/relationships/refs"
},
"related": {
"href": "https://developer.api.autodesk.com/data/v1/projects/b.56fded29-645c-44b6-9498-29c0f9517fec/items/urn:adsk.wipprod:dm.lineage:1sbrvwIVRJ6J_hnfeVDA2g/refs"
}
}
},
"links": {
"links": {
"self": {
"href": "https://developer.api.autodesk.com/data/v1/projects/b.56fded29-645c-44b6-9498-29c0f9517fec/items/urn:adsk.wipprod:dm.lineage:1sbrvwIVRJ6J_hnfeVDA2g/relationships/links"
}
}
}
}
},
"included": [
{
"type": "versions",
"id": "urn:adsk.wipprod:fs.file:vf.1sbrvwIVRJ6J_hnfeVDA2g?version=1",
"attributes": {
"name": "bandra ga.dwg",
"displayName": "bandra ga.dwg",
"createTime": "2021-02-16T11:06:47.0000000Z",
"createUserId": "8DCHNK3XFCM2",
"createUserName": "VBSL System Integrator",
"lastModifiedTime": "2021-02-16T11:08:00.0000000Z",
"lastModifiedUserId": "8DCHNK3XFCM2",
"lastModifiedUserName": "VBSL System Integrator",
"versionNumber": 1,
"storageSize": 2227450,
"fileType": "dwg",
"extension": {
"type": "versions:autodesk.bim360:File",
"version": "1.0",
"schema": {
"href": "https://developer.api.autodesk.com/schema/v1/versions/versions:autodesk.bim360:File-1.0"
},
"data": {
"processState": "PROCESSING_COMPLETE",
"extractionState": "SUCCESS",
"splittingState": "NOT_SPLIT",
"reviewState": "NOT_IN_REVIEW",
"revisionDisplayLabel": "1",
"sourceFileName": "bandra ga.dwg"
}
}
},
"links": {
"self": {
"href": "https://developer.api.autodesk.com/data/v1/projects/b.56fded29-645c-44b6-9498-29c0f9517fec/versions/urn:adsk.wipprod:fs.file:vf.1sbrvwIVRJ6J_hnfeVDA2g%3Fversion=1"
},
"webView": {
"href": "https://docs.b360.autodesk.com/projects/56fded29-645c-44b6-9498-29c0f9517fec/folders/urn%3Aadsk.wipprod%3Afs.folder%3Aco.nPlZOfdwQQiTrkXjS0FVVw/detail/viewer/items/urn%3Aadsk.wipprod%3Afs.file%3Avf.1sbrvwIVRJ6J_hnfeVDA2g%3Fversion%3D1"
}
},
"relationships": {
"item": {
"data": {
"type": "items",
"id": "urn:adsk.wipprod:dm.lineage:1sbrvwIVRJ6J_hnfeVDA2g"
},
"links": {
"related": {
"href": "https://developer.api.autodesk.com/data/v1/projects/b.56fded29-645c-44b6-9498-29c0f9517fec/versions/urn:adsk.wipprod:fs.file:vf.1sbrvwIVRJ6J_hnfeVDA2g%3Fversion=1/item"
}
}
},
"links": {
"links": {
"self": {
"href": "https://developer.api.autodesk.com/data/v1/projects/b.56fded29-645c-44b6-9498-29c0f9517fec/versions/urn:adsk.wipprod:fs.file:vf.1sbrvwIVRJ6J_hnfeVDA2g%3Fversion=1/relationships/links"
}
}
},
"refs": {
"links": {
"self": {
"href": "https://developer.api.autodesk.com/data/v1/projects/b.56fded29-645c-44b6-9498-29c0f9517fec/versions/urn:adsk.wipprod:fs.file:vf.1sbrvwIVRJ6J_hnfeVDA2g%3Fversion=1/relationships/refs"
},
"related": {
"href": "https://developer.api.autodesk.com/data/v1/projects/b.56fded29-645c-44b6-9498-29c0f9517fec/versions/urn:adsk.wipprod:fs.file:vf.1sbrvwIVRJ6J_hnfeVDA2g%3Fversion=1/refs"
}
}
},
"downloadFormats": {
"links": {
"related": {
"href": "https://developer.api.autodesk.com/data/v1/projects/b.56fded29-645c-44b6-9498-29c0f9517fec/versions/urn:adsk.wipprod:fs.file:vf.1sbrvwIVRJ6J_hnfeVDA2g%3Fversion=1/downloadFormats"
}
}
},
"derivatives": {
"data": {
"type": "derivatives",
"id": "dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLjFzYnJ2d0lWUko2Sl9obmZlVkRBMmc_dmVyc2lvbj0x"
},
"meta": {
"link": {
"href": "https://developer.api.autodesk.com/modelderivative/v2/designdata/dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLjFzYnJ2d0lWUko2Sl9obmZlVkRBMmc_dmVyc2lvbj0x/manifest?scopes=b360project.56fded29-645c-44b6-9498-29c0f9517fec,O2tenant.5902118"
}
}
},
"thumbnails": {
"data": {
"type": "thumbnails",
"id": "dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLjFzYnJ2d0lWUko2Sl9obmZlVkRBMmc_dmVyc2lvbj0x"
},
"meta": {
"link": {
"href": "https://developer.api.autodesk.com/modelderivative/v2/designdata/dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLjFzYnJ2d0lWUko2Sl9obmZlVkRBMmc_dmVyc2lvbj0x/thumbnail?scopes=b360project.56fded29-645c-44b6-9498-29c0f9517fec,O2tenant.5902118"
}
}
},
"storage": {
"data": {
"type": "objects",
"id": "urn:adsk.objects:os.object:wip.dm.prod/9ece42b9-c71c-4a27-90bb-87775f370164.dwg"
},
"meta": {
"link": {
"href": "https://developer.api.autodesk.com/oss/v2/buckets/wip.dm.prod/objects/9ece42b9-c71c-4a27-90bb-87775f370164.dwg?scopes=b360project.56fded29-645c-44b6-9498-29c0f9517fec,O2tenant.5902118"
}
}
}
}
}
]
}
It's here: dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLjFzYnJ2d0lWUko2Sl9obmZlVkRBMmc_dmVyc2lvbj0x
"derivatives": {
"data": {
"type": "derivatives",
"id": "dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLjFzYnJ2d0lWUko2Sl9obmZlVkRBMmc_dmVyc2lvbj0x"
},
"meta": {
"link": {
"href": "https://developer.api.autodesk.com/modelderivative/v2/designdata/dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLjFzYnJ2d0lWUko2Sl9obmZlVkRBMmc_dmVyc2lvbj0x/manifest?scopes=b360project.56fded29-645c-44b6-9498-29c0f9517fec,O2tenant.5902118"
}
}
},
To get the storage location of the an item (in your case urn:adsk.wipprod:dm.lineage:1sbrvwIVRJ6J_hnfeVDA2g), query the data of the tip (latest version) of the item using {{FORGE_HOST}}/data/v1/projects/:project/items/:item/tip (in your case, you can simply add /tip to your .links.self.href, ie. https://developer.api.autodesk.com/data/v1/projects/b.56fded29-645c-44b6-9498-29c0f9517fec/items/urn:adsk.wipprod:dm.lineage:1sbrvwIVRJ6J_hnfeVDA2g/tip.
This will return details of the latest version of the item (docs).
There, you should find data.relationships.storage.data.id, which is the the storage urn.

How do I pass secret value from keyvault using Azure ARM Template

I am trying to create Azure Application Gateway with ssl certificate from keyvaults. But didn't find any option to add keyvaults to ARM template with .pfx and .cer files. So I have encoded the certificate contents and added as secret in existing keyvault. Now trying to pass the secrets using ARM template. Validation passed but getting error in Deployment stage. Attached the template and parameters I am using.
Getting Error while deploying the resource
Deployment template validation failed: 'Template parameter JToken type is not valid. Expected 'String, Uri'. Actual 'Object'
"additionalInfo": [
{
"type": "TemplateViolation",
"info": {
"lineNumber": 226,
"linePosition": 33,
"path": "properties.template.parameters.appgwfesslcertsecret"
}
}
]
Updated Template:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"namingSettings": {
"type": "object"
},
"taggingSettings": {
"type": "object"
},
"applicationGatewaySettings": {
"type": "object"
},
"appgwfesslcertsecret": {
"type": "securestring"
},
"appgwbecertsecret": {
"type": "securestring"
}
},
"variables": {
"namePrefix": "[concat(parameters('namingSettings').name.org,'-',parameters('namingSettings').name.cloud,'-',parameters('namingSettings').name.region,'-',parameters('namingSettings').name.businessUnit,'-',parameters('namingSettings').name.account,'-',parameters('namingSettings').name.app,'-',parameters('namingSettings').name.sdlc,'-')]" },
"resources": [
{
"apiVersion": "2018-11-01",
"name": "[concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].name)]",
"type": "Microsoft.Network/applicationGateways",
"location": "[resourceGroup().location]",
"copy": {
"name": "appgwCopy",
"count": "[length(parameters('applicationGatewaySettings').settings)]"
},
"tags": "[parameters('taggingSettings').tags]",
"properties": {
"sku": {
"name": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].applicationGatewaySku]",
"tier": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].applicationGatewayTier]",
"capacity": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].applicationGatewayInstanceCount]"
},
"sslPolicy": {
"policyType": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].policyType]",
"policyName": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].policy]"
},
"copy": [
{
"name": "frontendPorts",
"count": "[length(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].frontendPorts)]",
"input": {
"name": "[concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].frontendPorts[copyIndex('frontendPorts')].name)]",
"properties": {
"port": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].frontendPorts[copyIndex('frontendPorts')].properties.port]"
}
}
},
{
"name": "gatewayIPConfigurations",
"count": "[length(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].gatewayIPConfigurations)]",
"input": {
"name": "[concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].gatewayIPConfigurations[copyIndex('gatewayIPConfigurations')].name)]",
"properties": {
"subnet": {
"id": "[resourceId(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].gatewayIPConfigurations[copyIndex('gatewayIPConfigurations')].properties.subnet.vnetRGName,'microsoft.network/virtualnetworks/subnets', parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].gatewayIPConfigurations[copyIndex('gatewayIPConfigurations')].properties.subnet.vnetName, parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].gatewayIPConfigurations[copyIndex('gatewayIPConfigurations')].properties.subnet.subnetName)]"
}
}
}
},
{
"name": "frontendIPConfigurations",
"count": "[length(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].frontendIPConfigurations)]",
"input": {
"name": "[concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].frontendIPConfigurations[copyIndex('frontendIPConfigurations')].name)]",
"properties": {
"subnet": {
"id": "[resourceId(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].gatewayIPConfigurations[copyIndex('frontendIPConfigurations')].properties.subnet.vnetRGName,'microsoft.network/virtualnetworks/subnets', parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].frontendIPConfigurations[copyIndex('frontendIPConfigurations')].properties.subnet.vnetName, parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].frontendIPConfigurations[copyIndex('frontendIPConfigurations')].properties.subnet.subnetName)]"
}
}
}
},
{
"name": "backendHttpSettingsCollection",
"count": "[length(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].backendHttpSettingsCollection)]",
"input": {
"name": "[concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].backendHttpSettingsCollection[copyIndex('backendHttpSettingsCollection')].name)]",
"properties": {
"port": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].backendHttpSettingsCollection[copyIndex('backendHttpSettingsCollection')].properties.port]",
"protocol": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].backendHttpSettingsCollection[copyIndex('backendHttpSettingsCollection')].properties.protocol]",
"authenticationCertificates": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].backendHttpSettingsCollection[copyIndex('backendHttpSettingsCollection')].properties.authenticationCertificates]"
}
}
},
{
"name": "backendAddressPools",
"count": "[length(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].backendAddressPools)]",
"input": {
"name": "[concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].backendAddressPools[copyIndex('backendAddressPools')].name)]"
}
},
{
"name": "httpListeners",
"count": "[length(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].httpListeners)]",
"input": {
"name": "[concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].httpListeners[copyIndex('httpListeners')].name)]",
"properties": {
"frontendIPConfiguration": {
"id": "[resourceId(resourceGroup().name, 'microsoft.network/applicationGateways/frontendIPConfigurations', concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].name),concat(variables('namePrefix'), parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].httpListeners[copyIndex('httpListeners')].properties.frontendIPConfiguration))]"
},
"frontendPort": {
"id": "[resourceId(resourceGroup().name, 'microsoft.network/applicationGateways/frontendPorts', concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].name),concat(variables('namePrefix'), parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].httpListeners[copyIndex('httpListeners')].properties.frontendPort))]"
},
"protocol": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].httpListeners[copyIndex('httpListeners')].properties.protocol]",
"sslCertificate": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].httpListeners[copyIndex('httpListeners')].properties.sslCertificate]"
}
}
},
{
"name": "requestRoutingRules",
"count": "[length(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].requestRoutingRules)]",
"input": {
"name": "[concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].requestRoutingRules[copyIndex('requestRoutingRules')].name)]",
"properties": {
"httpListener": {
"id": "[resourceId(resourceGroup().name, 'microsoft.network/applicationGateways/httpListeners', concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].name),concat(variables('namePrefix'), parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].requestRoutingRules[copyIndex('requestRoutingRules')].properties.httpListener))]"
},
"backendAddressPool": {
"id": "[resourceId(resourceGroup().name, 'microsoft.network/applicationGateways/backendAddressPools', concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].name),concat(variables('namePrefix'), parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].requestRoutingRules[copyIndex('requestRoutingRules')].properties.backendAddressPool))]"
},
"backendHttpSettings": {
"id": "[resourceId(resourceGroup().name, 'microsoft.network/applicationGateways/backendHttpSettingsCollection', concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].name),concat(variables('namePrefix'), parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].requestRoutingRules[copyIndex('requestRoutingRules')].properties.backendHttpSettings))]"
}
}
}
},
{
"name": "sslCertificates",
"count": "[length(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].sslCertificates)]",
"input": {
"name": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].sslCertificates[copyIndex('sslCertificates')].name]",
"properties": {
"data": "[parameters('appgwfesslcertsecret')]",
"password": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].sslCertificates[copyIndex('sslCertificates')].properties.password]"
}
}
},
{
"name": "authenticationCertificates",
"count": "[length(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].authenticationCertificates)]",
"input": {
"name": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].authenticationCertificates[copyIndex('authenticationCertificates')].name]",
"properties": {
"data": "[parameters('appgwbecertsecret')]"
}
}
}
],
"probes": [],
"webApplicationFirewallConfiguration": {
"enabled": true,
"firewallMode": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].firewallMode]",
"ruleSetType": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].ruleSetType]",
"ruleSetVersion": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].ruleSetVersion]",
"requestBodyCheck": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].requestBodyCheck]",
"maxRequestBodySizeInKb": "[if(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].requestBodyCheck, parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].maxReqBodySize, json('null'))]",
"fileUploadLimitInMb": "[int(100)]"
},
"enableHttp2": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].enableHTTP2]"
},
"resources": [
{
"type": "providers/diagnosticSettings",
"name": "[concat('Microsoft.Insights/', parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].diagname)]",
"dependsOn": [
"[concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].name)]"
],
"apiVersion": "2017-05-01-preview",
"properties": {
"name": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].diagname]",
"logs": [
{
"category": "ApplicationGatewayAccessLog",
"enabled": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].enableApplicationGatewayAccessLog]",
"retentionPolicy": {
"days": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].applicationGatewayAccessLogRetentionDays]",
"enabled": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].enableApplicationGatewayAccessLogRetention]"
}
},
{
"category": "ApplicationGatewayPerformanceLog",
"enabled": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].enableApplicationGatewayPerformanceLog]",
"retentionPolicy": {
"days": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].applicationGatewayPerformanceLogRetentionDays]",
"enabled": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].enableApplicationGatewayPerformanceLogRetention]"
}
},
{
"category": "ApplicationGatewayFirewallLog",
"enabled": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].enableApplicationGatewayFirewallLog]",
"retentionPolicy": {
"days": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].applicationGatewayFirewallLogRetentionDays]",
"enabled": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].enableApplicationGatewayFirewallLogRetention]"
}
}
],
"metrics": [
{
"category": "AllMetrics",
"enabled": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].enableAllMetrics]",
"retentionPolicy": {
"enabled": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].enableAllMetricsRetentionPolicy]",
"days": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].allMetricsRetentionDays]"
}
}
]
}
}
]
}
],
"outputs": {}
}
Updated Parameter File:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"namingSettings": {
"value": {
"name": {
"app": "demo",
"cloud": "azu",
"region": "eus2",
}
}
},
"taggingSettings": {
"value": {
"tags": {
"AppID": "demo",
"Environment": "nonprod",
}
}
},
"applicationGatewaySettings": {
"value": {
"settings": [
{
"name": "appgw-pcs01",
"applicationGatewaySku": "WAF_Medium",
"applicationGatewayTier": "WAF",
"applicationGatewayInstanceCount": 2,
"policyType": "Predefined",
"policy": "AppGwSslPolicy20170401S",
"publicIP": null,
"firewallMode": "Prevention",
"diagname": "Demo-Appgw",
"ruleSetType": "OWASP",
"ruleSetVersion": "3.0",
"requestBodyCheck": true,
"maxReqBodySize": 10,
"enableHTTP2": false,
"enableApplicationGatewayAccessLog": true,
"applicationGatewayAccessLogRetentionDays": 30,
"enableApplicationGatewayAccessLogRetention": true,
"enableApplicationGatewayPerformanceLog": true,
"applicationGatewayPerformanceLogRetentionDays": 30,
"enableApplicationGatewayPerformanceLogRetention": true,
"enableApplicationGatewayFirewallLog": true,
"applicationGatewayFirewallLogRetentionDays": 30,
"enableApplicationGatewayFirewallLogRetention": true,
"enableAllMetrics": true,
"enableAllMetricsRetentionPolicy": true,
"allMetricsRetentionDays": 30,
"frontendPorts": [
{
"name": "feport-80",
"properties": {
"port": 80
}
},
{
"name": "feport-443",
"properties": {
"port": 443
}
}
],
"gatewayIPConfigurations": [
{
"name": "gwipconfig-pcs01",
"properties": {
"subnet": {
"vnetName": "demo-vnet",
"vnetRGName": "demo",
"subnetName": "demo-subgw"
}
}
}
],
"sslCertificates": [
{
"name": "appgwfesslcert",
"properties": {
"data": null,
"password": "password"
}
}
],
"authenticationCertificates": [
{
"name": "appgwbecert",
"properties": {
"data": null
}
}
],
"frontEndIPConfigurations": [
{
"name": "feipcfg-pcs01",
"properties": {
"subnet": {
"vnetName": "demo-vnet",
"vnetRGName": "demo",
"subnetName": "demo-subgw"
}
}
}
],
"httpListeners": [
{
"name": "httplistener-pcs01",
"properties": {
"frontendIPConfiguration": "feipcfg-pcs01",
"frontendPort": "feport-80",
"protocol": "Http",
"sslCertificate": {}
}
},
{
"name": "httpslistener-pcs01",
"properties": {
"frontendIPConfiguration": "feipcfg-pcs01",
"frontendPort": "feport-443",
"protocol": "Https",
"sslCertificate": {
"id": "/subscriptions/105dcee5-gy46-48e3-9046-265c7379e647/resourceGroups/demo/providers/Microsoft.Network/applicationGateways/azu-eus2-nonprod-appgw-pcs01/sslCertificates/appgwfesslcert"
}
}
}
],
"backendHttpSettingsCollection": [
{
"name": "httpsetcol-default",
"properties": {
"protocol": "Http",
"port": 80,
"authenticationCertificates": []
}
},
{
"name": "httpssetcol-default",
"properties": {
"protocol": "Https",
"port": 443,
"authenticationCertificates": [
{
"id": "/subscriptions/105dcee5-gy46-48e3-9046-265c7379e647/resourceGroups/demo/providers/Microsoft.Network/applicationGateways/azu-eus2-nonprod-appgw-pcs01/authenticationCertificates/appgwbecert"
}
]
}
}
],
"backendAddressPools": [
{
"name": "beap-pcs01"
}
],
"requestRoutingRules": [
{
"name": "httpreqrtrule-pcs01",
"properties": {
"httpListener": "httplistener-pcs01",
"backendAddressPool": "beap-pcs01",
"backendHttpSettings": "httpsetcol-default"
}
},
{
"name": "httpsreqrtrule-pcs01",
"properties": {
"httpListener": "httpslistener-pcs01",
"backendAddressPool": "beap-pcs01",
"backendHttpSettings": "httpssetcol-default"
}
}
]
}
]
}
},
"appgwfesslcertsecret": {
"value": {
"reference": {
"keyVault": {
"id": "/subscriptions/105dcee5-gy46-48e3-9046-265c7379e647/resourceGroups/demo/providers/Microsoft.KeyVault/vaults/demo-kv-new"
},
"secretName": "appgwfesslcert"
}
}
},
"appgwbecertsecret": {
"value": {
"reference": {
"keyVault": {
"id": "/subscriptions/105dcee5-gy46-48e3-9046-265c7379e647/resourceGroups/demo/providers/Microsoft.KeyVault/vaults/demo-kv-new"
},
"secretName": "appgwbecert"
}
}
}
}
}
you can only reference KV secrets in the parameters section of the template (or parameters file). You cannot use it in a random place in the template
https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-tutorial-use-key-vault

How to get a value of a object from its foreign key?

Im using Backand to store my data. I have an object, Events, that references another object, Locations.
{
"name": "events",
"fields": {
"eventCommentsId": {
"collection": "comments",
"via": "eventId"
},
"tags": {
"collection": "events_tags",
"via": "event"
},
"users": {
"collection": "users_events",
"via": "event"
},
"name": {
"type": "string"
},
"date": {
"type": "datetime"
},
"time": {
"type": "datetime"
},
"info": {
"type": "text"
},
"locationId": {
"object": "locations"
}
},
{
"name": "locations",
"fields": {
"events": {
"collection": "events",
"via": "locationId"
},
"name": {
"type": "text"
},
"geo": {
"type": "point"
}
}
}
When I try to display the location of the event, I can only get the value of locationID. I want the actual name of the location, not the id. How do I do that?
<ion-list>
<ion-item class="item item-thumbnail-left" ng-repeat="event in events" type="item-text-wrap" href="#/event-detail/{{event.id}}">
<h2>{{event.name}}</h2>
<p><i class="ion-location"></i> {{event.locationId.name}}</p>
<ion-option-button class="button-assertive" ng-click="deleteEvent(event.id)">
Delete
</ion-option-button>
</ion-item>
</ion-list>
angular code
.service('EventService', function ($http, Backand) {
var baseUrl = '/1/objects/';
var objectName = 'events/';
function getUrl() {
return Backand.getApiUrl() + baseUrl + objectName;
}
function getUrlForId(id) {
return getUrl() + id;
}
getEvents = function () {
return $http.get(getUrl());
};
addEvent = function(event) {
return $http.post(getUrl(), event);
}
deleteEvent = function (id) {
return $http.delete(getUrlForId(id));
};
getEvent = function (id) {
return $http.get(getUrlForId(id));
};
return {
getEvents: getEvents,
addEvent: addEvent,
deleteEvent: deleteEvent,
getEvent: getEvent
}
})
.controller('FeedCtrl', ['$scope', '$ionicModal', '$ionicSideMenuDelegate', 'EventService', function($scope, $ionicModal, $ionicSideMenuDelegate, EventService) {
$scope.events = [];
$scope.input = {};
function getAllEvents() {
EventService.getEvents()
.then(function (result) {
$scope.events = result.data.data;
});
}
$scope.addEvent = function() {
EventService.addEvent($scope.input)
.then(function(result) {
$scope.input = {};
getAllEvents();
});
}
$scope.deleteEvent = function(id) {
EventService.deleteEvent(id)
.then(function (result) {
getAllEvents();
});
}
getAllEvents();
}])
There are two options. You can either use the descriptive value in the __metadata of each object like this:
request: https://api.backand.com/1/objects/events?pageSize=20&pageNumber=1
response:
{
"totalRows": 2,
"data": [
{
"__metadata": {
"id": "1",
"fields": {
"id": {
"type": "int",
"unique": true
},
"name": {
"type": "string"
},
"date": {
"type": "datetime"
},
"time": {
"type": "datetime"
},
"info": {
"type": "text"
},
"locationId": {
"object": "locations"
}
},
"descriptives": {
"locationId": {
"label": "Madison Square Garden",
"value": "1"
}
},
"dates": {
"date": "",
"time": ""
}
},
"id": 1,
"name": "knicks vs warriors",
"date": null,
"time": null,
"info": "",
"locationId": "1"
},
{
"__metadata": {
"id": "2",
"fields": {
"id": {
"type": "int",
"unique": true
},
"name": {
"type": "string"
},
"date": {
"type": "datetime"
},
"time": {
"type": "datetime"
},
"info": {
"type": "text"
},
"locationId": {
"object": "locations"
}
},
"descriptives": {
"locationId": {
"label": "Madison Square Garden",
"value": "1"
}
},
"dates": {
"date": "",
"time": ""
}
},
"id": 2,
"name": "knicks vs cavs",
"date": null,
"time": null,
"info": "",
"locationId": "1"
}
]
}
or you can do a deep request and get the value in the relatedObjects
request: https://api.backand.com/1/objects/events?pageSize=20&pageNumber=1&deep=true
response:
{
"totalRows": 2,
"data": [
{
"__metadata": {
"id": "1",
"fields": {
"id": {
"type": "int",
"unique": true
},
"name": {
"type": "string"
},
"date": {
"type": "datetime"
},
"time": {
"type": "datetime"
},
"info": {
"type": "text"
},
"locationId": {
"object": "locations"
}
},
"descriptives": {
"locationId": {
"label": "Madison Square Garden",
"value": "1"
}
},
"dates": {
"date": "",
"time": ""
}
},
"id": 1,
"name": "knicks vs warriors",
"date": null,
"time": null,
"info": "",
"locationId": "1"
},
{
"__metadata": {
"id": "2",
"fields": {
"id": {
"type": "int",
"unique": true
},
"name": {
"type": "string"
},
"date": {
"type": "datetime"
},
"time": {
"type": "datetime"
},
"info": {
"type": "text"
},
"locationId": {
"object": "locations"
}
},
"descriptives": {
"locationId": {
"label": "Madison Square Garden",
"value": "1"
}
},
"dates": {
"date": "",
"time": ""
}
},
"id": 2,
"name": "knicks vs cavs",
"date": null,
"time": null,
"info": "",
"locationId": "1"
}
],
"relatedObjects": {
"locations": {
"1": {
"__metadata": {
"id": "1",
"fields": {
"id": {
"type": "int",
"unique": true
},
"events": {
"collection": "events",
"via": "locationId"
},
"name": {
"type": "text"
},
"geo": {
"type": "point"
}
},
"descriptives": {},
"dates": {}
},
"id": 1,
"events": null,
"name": "Madison Square Garden",
"geo": [
40.7505,
73.9934
]
}
}
}
}
search for Madison Square Garden as the name of the location to understand the JSON structure.
You can set the descriptive field in the Object Settings