Loop through a query to pull substrings in KQL/Grafana? - json

So I need to pull the some substrings from the following data from a query
[
{
"rel": "System.LinkTypes.Hierarchy-Forward",
"url": "https://fakelink/workItems/247155",
"attributes": {
"isLocked": false,
"name": "Child"
}
},
{
"rel": "System.LinkTypes.Hierarchy-Forward",
"url": "https://fakelink/workItems/247154 ",
"attributes": {
"isLocked": false,
"name": "Child"
}
},
{
"rel": "System.LinkTypes.Hierarchy-Forward",
"url": "https://fakelink/247160",
"attributes": {
"isLocked": false,
"name": "Child"
}
},
{
"rel": "System.LinkTypes.Hierarchy-Forward",
"url": "https://fakelink/247156",
"attributes": {
"isLocked": false,
"name": "Child"
}
},
{
"rel": "System.LinkTypes.Hierarchy-Forward",
"url": "https://fakelink/workItems/247159",
"attributes": {
"isLocked": false,
"name": "Child"
}
},
{
"rel": "System.LinkTypes.Hierarchy-Forward",
"url": "https://fakelink/workItems/247157",
"attributes": {
"isLocked": false,
"name": "Child"
}
},
{
"rel": "System.LinkTypes.Hierarchy-Forward",
"url": "https://fakelink/247158",
"attributes": {
"isLocked": false,
"name": "Child"
}
}
]
In grafana obviously having that long string in a table is useless to me. I need to somehow parse the data and pull the number at the end of each web link as well as the "Child" phrases and somehow connect those preferably as a Child column (or whatever phrase is in that spot) with the numbers at the end of the web links being the data in the table. I was told I needed to "write a loop to go through the JSON" any help at all, suggestions, anything, would be massively appreciated
note: the string is different for every single item the query pulled up and there's a couple thousand

mv-expand operator, to explode the array.
parse operator, to extract the number from each url.
datatable(doc:dynamic)[dynamic([ { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/workItems/247155", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/workItems/247154 ", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/247160", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/247156", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/workItems/247159", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/workItems/247157", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/247158", "attributes": { "isLocked": false, "name": "Child" } } ])]
| mv-expand doc
| project doc.url
| parse doc_url with * "/" num:long
doc_url
num
https://fakelink/workItems/247155
247155
https://fakelink/workItems/247154
247154
https://fakelink/247160
247160
https://fakelink/247156
247156
https://fakelink/workItems/247159
247159
https://fakelink/workItems/247157
247157
https://fakelink/247158
247158
Fiddle

Related

Automate JSON substrings with semi-random data to KQL?

So currently I have the following simple code to just build out a table for myself and look at data
azure_devops_work_item_events_CL
| summarize any(WorkItemType_s, TeamProject_s, Title_s,
AssignedTo_s, State_s, Reason_s) by WorkItemId_d, Relations_s
| order by WorkItemId_d desc
My problem is the Relations_s data is pulling a super long string that's different in length pretty much every instance although the format is the same for each one ex:
Relations_s
[ { "rel": "System.LinkTypes.Hierarchy-Reverse", "url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/197138", "attributes": { "isLocked": false, "name": "Parent" } } ]
[ { "rel": "System.LinkTypes.Hierarchy-Reverse", "url": "https://dev.azure.com/xxxx/d88804f3-b064-4489-9705/_apis/wit/workItems/234449", "attributes": { "isLocked": false, "name": "Parent" } } ]
[ { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/247970", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/242838", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/242835", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/246163", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/234839", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/229566", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/228347", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/240648", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/234833", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/240647", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/242837", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/234803", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/234801", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/246352", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/242839", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/234834", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/234838", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/242836", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Reverse", "url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/218335", "attributes": { "isLocked": false, "name": "Parent" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/234832", "attributes": { "isLocked": false, "name": "Child" } } ]
This is a small sample of what my table looks like when I query it. I'm completely lost on how I can parse the table in such a way that I'm able to automate pulling the number at the end of every link and the name portion at the end of each string. Especially when some parts of the table have 40 strings in 1. Note all the data is in the form of a JSON if that impacts this at all. The end result needs to look something like this
Child
Parent
240241
240541
Or this
Item
Link
240241
Child
240541
Parent
Apologies for the formatting I can't get the massive data set to properly format into a table
According to its name Relations_s is probably a string, therefore needs conversion to JSON (by using todynamic()).
Option 1
azure_devops_work_item_events_CL
| mv-apply todynamic(Relations_s) on
(
parse Relations_s.url with * "/" Item:long
| project Item
,Link = Relations_s.attributes.name
| summarize Parent = take_anyif (Item ,Link == "Parent")
,Children = make_list_if (Item ,Link == "Child")
)
Parent
Children
197138
[]
234449
[]
218335
[247970,242838,242835,246163,234839,229566,228347,240648,234833,240647,242837,234803,234801,246352,242839,234834,234838,242836,234832]
Option 2
azure_devops_work_item_events_CL
| mv-apply todynamic(Relations_s) on
(
parse Relations_s.url with * "/" Item:long
| project Item
,Link = Relations_s.attributes.name
| summarize Parent = take_anyif (Item ,Link == "Parent")
,Children = make_list_if (Item ,Link == "Child")
| mv-expand Children = iff(array_length(Children) == 0, dynamic(null), Children) to typeof(long)
)
Parent
Children
197138
234449
218335
247970
218335
242838
218335
242835
218335
246163
218335
234839
218335
229566
218335
228347
218335
240648
218335
234833
218335
240647
218335
242837
218335
234803
218335
234801
218335
246352
218335
242839
218335
234834
218335
234838
218335
242836
218335
234832
If I understood your description correctly, you could try the following, using the mv-apply and parse operators:
datatable(d:dynamic)
[
dynamic([
{
"rel": "System.LinkTypes.Hierarchy-Reverse",
"url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/197138",
"attributes": {
"isLocked": false,
"name": "Parent"
}
}
]), dynamic([
{
"rel": "System.LinkTypes.Hierarchy-Reverse",
"url": "https://dev.azure.com/xxxx/d88804f3-b064-4489-9705/_apis/wit/workItems/234449",
"attributes": {
"isLocked": false,
"name": "Parent"
}
}
]), dynamic([
{
"rel": "System.LinkTypes.Hierarchy-Forward",
"url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/247970",
"attributes": {
"isLocked": false,
"name": "Child"
}
},
{
"rel": "System.LinkTypes.Hierarchy-Forward",
"url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/242838",
"attributes": {
"isLocked": false,
"name": "Child"
}
},
{
"rel": "System.LinkTypes.Hierarchy-Forward",
"url": "https://dev.azure.com/xxxx/a69ffa35-e99f-42ea-a254/_apis/wit/workItems/242835",
"attributes": {
"isLocked": false,
"name": "Child"
}
}
]),
]
| mv-apply d on (
parse d with * "/workItems/" item:long *
| extend link = tostring(d.attributes.name)
)
| project item, link
item
link
197138
Parent
234449
Parent
247970
Child
242838
Child
242835
Child

JSON formatting for Terraform API

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
}
}
]
}

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.

ARM Templates - Values and parameters for Adding Dynamic Data disks to VMs?

I'm new to ARM Templates.
I've downloaded an ARM Template from the Portal after building a VM with 1 managed Data Disk.
My objective is to use ARM Templates to build several VMs in a row.
For now, with identical parameters, except for the VM Name and of course NIC and Disks Names.
I noticed the parameters.json file had hardcoded values and that wouldn't work as a template, so I started modifying to see how could I make it more dynamic.
However I don't understand the Data Disks structure, which, in this template, is divided among different components and that's making me struggle with Dynamic Naming for the Disks.
Data disks appear in the template as a Resource and then as a property of the VM, inside a copy function.
However in the parameters file there are two objects, dataDisks and dataDisksResources.
I don't understand why the parameters have two different objects instead of one (for example, everything inside dataDisks instead of also having a dataDisksResources) and I also don't get why the parameters of the VM disk property are different and more than the parameters of the Disk Resource.
This is the template.json
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string"
},
"subnetName": {
"type": "string"
},
"virtualNetworkId": {
"type": "string"
},
"virtualMachineName": {
"type": "string"
},
"virtualMachineRG": {
"type": "string"
},
"osDiskType": {
"type": "string"
},
"dataDisks": {
"type": "array"
},
"dataDiskResources": {
"type": "array"
},
"virtualMachineSize": {
"type": "string"
},
"adminUsername": {
"type": "string"
},
"adminPassword": {
"type": "secureString"
},
"diagnosticsStorageAccountName": {
"type": "string"
},
"diagnosticsStorageAccountId": {
"type": "string"
},
"diagnosticsStorageAccountType": {
"type": "string"
},
"diagnosticsStorageAccountKind": {
"type": "string"
}
},
"variables": {
"vnetId": "[parameters('virtualNetworkId')]",
"subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]",
"nicName": "[concat(parameters('virtualMachineName'), substring(uniqueString(resourceGroup().id),0,4))]"
},
"resources": [
{
"name": "[variables('nicName')]",
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2019-07-01",
"location": "[parameters('location')]",
"dependsOn": [],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"subnet": {
"id": "[variables('subnetRef')]"
},
"privateIPAllocationMethod": "Dynamic"
}
}
]
},
"tags": {
}
},
{
"name": "[concat(parameters('virtualMachineName'),'_DataDisk_0')]",
"type": "Microsoft.Compute/disks",
"apiVersion": "2019-07-01",
"location": "[parameters('location')]",
"properties": "[parameters('dataDiskResources')[copyIndex()].properties]",
"sku": {
"name": "[parameters('dataDiskResources')[copyIndex()].sku]"
},
"copy": {
"name": "managedDiskResources",
"count": "[length(parameters('dataDiskResources'))]"
},
"tags": {
}
},
{
"name": "[parameters('virtualMachineName')]",
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2019-07-01",
"location": "[parameters('location')]",
"dependsOn": [
"managedDiskResources",
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]",
"[concat('Microsoft.Storage/storageAccounts/', parameters('diagnosticsStorageAccountName'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('virtualMachineSize')]"
},
"storageProfile": {
"osDisk": {
"createOption": "fromImage",
"managedDisk": {
"storageAccountType": "[parameters('osDiskType')]"
}
},
"imageReference": {
"publisher": "MicrosoftVisualStudio",
"offer": "VisualStudio",
"sku": "VS-2017-Ent-Latest-Win10-N",
"version": "latest"
},
"copy": [
{
"name": "dataDisks",
"count": "[length(parameters('dataDisks'))]",
"input": {
"lun": "[parameters('dataDisks')[copyIndex('dataDisks')].lun]",
"createOption": "[parameters('dataDisks')[copyIndex('dataDisks')].createOption]",
"caching": "[parameters('dataDisks')[copyIndex('dataDisks')].caching]",
"writeAcceleratorEnabled": "[parameters('dataDisks')[copyIndex('dataDisks')].writeAcceleratorEnabled]",
"diskSizeGB": "[parameters('dataDisks')[copyIndex('dataDisks')].diskSizeGB]",
"managedDisk": {
"id": "[coalesce(parameters('dataDisks')[copyIndex('dataDisks')].id, if(equals(parameters('dataDisks')[copyIndex('dataDisks')].name, json('null')), json('null'), resourceId('Microsoft.Compute/disks', parameters('dataDisks')[copyIndex('dataDisks')].name)))]",
"storageAccountType": "[parameters('dataDisks')[copyIndex('dataDisks')].storageAccountType]"
}
}
}
]
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]"
}
]
},
"osProfile": {
"computerName": "[parameters('virtualMachineName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]",
"windowsConfiguration": {
"enableAutomaticUpdates": true,
"provisionVmAgent": true
}
},
"licenseType": "Windows_Server",
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "[concat('https://', parameters('diagnosticsStorageAccountName'), '.blob.core.windows.net/')]"
}
}
},
"tags": {
}
},
{
"name": "[parameters('diagnosticsStorageAccountName')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"location": "[parameters('location')]",
"properties": {},
"kind": "[parameters('diagnosticsStorageAccountKind')]",
"sku": {
"name": "[parameters('diagnosticsStorageAccountType')]"
},
"tags": {
}
}
],
"outputs": {
"adminUsername": {
"type": "string",
"value": "[parameters('adminUsername')]"
}
}
}
And this is the parameters.json
{
"location": {
"value": "location"
},
"subnetName": {
"value": "subnetname"
},
"virtualNetworkId": {
"value": "networkid"
},
"virtualMachineRG": {
"value": "vmRG"
},
"osDiskType": {
"value": "Standard_LRS"
},
"dataDisks": {
"value": [
{
"lun": 0,
"createOption": "attach",
"caching": "None",
"writeAcceleratorEnabled": false,
"id": null,
"storageAccountType": null,
"name": null,
"diskSizeGB": null,
"diskEncryptionSet": {
"id": null
}
}
]
},
"dataDiskResources": {
"value": [
{
"sku": "Standard_LRS",
"properties": {
"diskSizeGB": 128,
"creationData": {
"createOption": "empty"
}
}
}
]
},
"virtualMachineSize": {
"value": "Standard_B4ms"
},
"adminUsername": {
"value": "admin"
},
"diagnosticsStorageAccountName": {
"value": "rg01diag"
},
"diagnosticsStorageAccountId": {
"value": "Microsoft.Storage/storageAccounts/rg01diag"
},
"diagnosticsStorageAccountType": {
"value": "Standard_LRS"
},
"diagnosticsStorageAccountKind": {
"value": "Storage"
} }
I also can't find any documentation for this kind of template. All the quick templates I find have a simpler version of this. For example they state all the disks properties inside the same template file, the parameters and properties are fewer and there isn't any dataDisksResources object anywhere.
I want to understand how would I need to modify these Disk structure to add dynamic naming that names them, for example, as Azure portal does (VMName_DataDisk_Lunnumber)
Because you have to specify different input when you create the data disk and when you attach it, but you dont have to create it, you can just tell the VM to create those. thsis would be one way of doing that:
"dataDisks": [
{
"diskSizeGB": "[parameters('sizeOfEachDataDiskInGB')]",
"lun": 0,
"createOption": "Empty"
},
{
"diskSizeGB": "[parameters('sizeOfEachDataDiskInGB')]",
"lun": 1,
"createOption": "Empty"
},
{
"diskSizeGB": "[parameters('sizeOfEachDataDiskInGB')]",
"lun": 2,
"createOption": "Empty"
},
{
"diskSizeGB": "[parameters('sizeOfEachDataDiskInGB')]",
"lun": 3,
"createOption": "Empty"
}
],
and you dont have to have a separate disk resource, these would be created automatically. you can also add a property called name to specify a name for those.
https://github.com/Azure/azure-quickstart-templates/blob/master/101-vm-multiple-data-disk/azuredeploy.json

EmberJS JSONAPIAdapter with hasMany + embedded relationships

In addition to my last question ember.js JSONAPIAdapter with hasMany a colleague asked if the "kind-of"-sideloaded relationships in the working
JSON:API structure could be embedded like this:
{
"data": [
{
"type": "altersgruppe",
"id": "1",
"attributes": {
"name": "UNTER_21"
},
"relationships": {
"tarifbeitraege": {
"data": [
{
"type": "tarifbeitrag",
"id": "3",
"attributes": {
"name": "ZAHN70",
"beitrag": "3-29,70",
"proergaenzung": "7,00",
"gesamtbeitrag": "25.99"
}
},
{
"type": "tarifbeitrag",
"id": "4",
"attributes": {
"name": "ZAHN90",
"beitrag": "4-28,70",
"proergaenzung": "7,00",
"gesamtbeitrag": "30.99"
}
}
]
}
}
},
{
"type": "altersgruppe",
"id": "2",
"attributes": {
"name": "ALTER_21_24"
},
"relationships":{
"tarifbeitraege": {
"data": [
{
"type": "tarifbeitrag",
"id": "1",
"attributes": {
"name": "ZAHN70",
"beitrag": "1-25,70",
"proergaenzung": "7,00",
"gesamtbeitrag": "25.99"
}
},
{
"type": "tarifbeitrag",
"id": "2",
"attributes": {
"name": "ZAHN90",
"beitrag": "2-25,70",
"proergaenzung": "7,00",
"gesamtbeitrag": "25.99"
}
}]
}
}
}
]
}
The idea behind that: We can use relationships with less problems in the java backend (where sideloaded structures are harder to implement).
But the JSON above structure does not work. The store contains only the first level of data, which is "altersgruppe", but "tarifbeitraege" are empty.
This type of document is referred to as a compound document in the JSON:API specification.
The "relationships" section of a compound document is supposed to have only the relationships - individual objects there are supposed to be resource identifier objects. Putting attributes there doesn't work because that's not where they are supposed to be.
Instead, the full objects are side-loaded in a top-level "included" section. Thus, your response should probably look more like this:
{
"data": [
{
"type": "altersgruppe",
"id": "1",
"attributes": {
"name": "UNTER_21"
},
"relationships": {
"tarifbeitraege": {
"data": [
{ "type": "tarifbeitrag", "id": "3" },
{ "type": "tarifbeitrag", "id": "4" }
]
}
}
},
{
"type": "altersgruppe",
"id": "2",
"attributes": {
"name": "ALTER_21_24"
},
"relationships":{
"tarifbeitraege": {
"data": [
{ "type": "tarifbeitrag", "id": "1" },
{ "type": "tarifbeitrag", "id": "2" }
]
}
}
}
],
"included": [
{
"type": "tarifbeitrag",
"id": "3",
"attributes": {
"name": "ZAHN70",
"beitrag": "3-29,70",
"proergaenzung": "7,00",
"gesamtbeitrag": "25.99"
}
},
{
"type": "tarifbeitrag",
"id": "4",
"attributes": {
"name": "ZAHN90",
"beitrag": "4-28,70",
"proergaenzung": "7,00",
"gesamtbeitrag": "30.99"
}
},
{
"type": "tarifbeitrag",
"id": "1",
"attributes": {
"name": "ZAHN70",
"beitrag": "1-25,70",
"proergaenzung": "7,00",
"gesamtbeitrag": "25.99"
}
},
{
"type": "tarifbeitrag",
"id": "2",
"attributes": {
"name": "ZAHN90",
"beitrag": "2-25,70",
"proergaenzung": "7,00",
"gesamtbeitrag": "25.99"
}
}
]
}
There's an example on the home page of http://jsonapi.org that shows an example that includes a side load, as well as one in the section of the specification describing compound documents.