There is a step in my Azure pipeline yaml that requires the step number of the first failed step. Is there a way to retrieve this information (preferably in a bash task)?
The idea is to retrieve the logs of the failed step .../_apis/build/builds/777777/logs/3
I'm not good at bash scripting but you need to:
Call Azure DevOps REST API first on timeline endpoint:
https://dev.azure.com/{{organization}}/{{project}}/_apis/build/builds/3477/timeline?api-version=6.0
where 3477 is your build id.
Then go through response and find first record with result=failed:
{
"previousAttempts": [],
"id": "5caf77c8-9b10-50ef-b5c7-ca89c63e1c86",
"parentId": "12f1170f-54f2-53f3-20dd-22fc7dff55f9",
"type": "Task",
"name": "Run a multi-line script",
"startTime": "2020-09-07T12:00:04.5033333Z",
"finishTime": "2020-09-07T12:00:04.7466667Z",
"currentOperation": null,
"percentComplete": null,
"state": "completed",
"result": "failed",
"resultCode": null,
"changeId": 10,
"lastModified": "0001-01-01T00:00:00",
"workerName": "Hosted Agent",
"order": 4,
"details": null,
"errorCount": 1,
"warningCount": 0,
"url": null,
"log": {
"id": 7,
"type": "Container",
"url": "https://dev.azure.com/thecodemanual/4fa6b279-3db9-4cb0-aab8-e06c2ad550b2/_apis/build/builds/3477/logs/7"
},
"task": {
"id": "d9bafed4-0b18-4f58-968d-86655b4d2ce9",
"name": "CmdLine",
"version": "2.164.2"
},
"attempt": 1,
"identifier": null,
"issues": [
{
"type": "error",
"category": "General",
"message": "Bash exited with code '1'.",
"data": {
"type": "error",
"logFileLineNumber": "15"
}
}
]
},
At log property of this record you will find url to your log
"log": {
"id": 7,
"type": "Container",
"url": "https://dev.azure.com/thecodemanual/4fa6b279-3db9-4cb0-aab8-e06c2ad550b2/_apis/build/builds/3477/logs/7"
},
Related
I want to save data that the user has entered in my database.
I need an ID that will be unique for all conversations with the same user rather than for a single conversation.
According to the documentation, I need to use the From.ID field from the Channel Account data.
But when I use Bot Framework Emulator and click Restart with same User ID, the ID of the user changes and what remains is the bot ID.
What field should I use to identify a user across different calls (in the same channel, of course)?
In this example, I see that the the Recipient.id identifier that the bot sends does not change.
Is this the user's unique identifier? Why is it be different from the From.ID?
Conversation 1:
Message from the bot:
{
"channelId": "emulator",
"conversation": {
"id": "202d2d60-4c7f-11e9-b1fa-8b3537dcca45|livechat"
},
"from": {
"id": "2",
"name": "Bot",
"role": "bot"
},
"id": "208f2380-4c7f-11e9-98ea-9595460a8f6e",
"inputHint": "acceptingInput",
"localTimestamp": "2019-03-22T10:47:30+02:00",
"locale": "",
"recipient": {
"id": "d4d1b5a6-1797-4d2a-b78e-257de71d3a69",
"role": "user"
},
"replyToId": "20559cf0-4c7f-11e9-98ea-9595460a8f6e",
"serviceUrl": "http://localhost:53634",
"showInInspector": true,
"text": "conversationUpdate event detected",
"timestamp": "2019-03-22T08:47:30.232Z",
"type": "message"
}
Message from the user:
{
"channelData": {
"clientActivityID": "15532445742330.iqwrgb646rq",
"state": "sent"
},
"channelId": "emulator",
"conversation": {
"id": "202d2d60-4c7f-11e9-b1fa-8b3537dcca45|livechat"
},
"entities": [
{
"requiresBotState": true,
"supportsListening": true,
"supportsTts": true,
"type": "ClientCapabilities"
}
],
"from": {
"id": "r_wg30czmqjt",
"name": "User",
"role": "user"
},
"id": "6a791af0-4c7f-11e9-98ea-9595460a8f6e",
"localTimestamp": "2019-03-22T10:49:34+02:00",
"locale": "",
"recipient": {
"id": "2",
"name": "Bot",
"role": "bot"
},
"serviceUrl": "http://localhost:53634",
"showInInspector": true,
"text": "hi",
"textFormat": "plain",
"timestamp": "2019-03-22T08:49:34.239Z",
"type": "message"
}
Conversation 2 (After Restart with same user ID):
Message from the bot:
{
"channelId": "emulator",
"conversation": {
"id": "a10fba20-4c83-11e9-b1fa-8b3537dcca45|livechat"
},
"from": {
"id": "2",
"name": "Bot",
"role": "bot"
},
"id": "a15611f0-4c83-11e9-98ea-9595460a8f6e",
"inputHint": "acceptingInput",
"localTimestamp": "2019-03-22T11:19:44+02:00",
"locale": "",
"recipient": {
"id": "d4d1b5a6-1797-4d2a-b78e-257de71d3a69",
"role": "user"
},
"replyToId": "a116e610-4c83-11e9-98ea-9595460a8f6e",
"serviceUrl": "http://localhost:53634",
"showInInspector": true,
"text": "conversationUpdate event detected",
"timestamp": "2019-03-22T09:19:44.271Z",
"type": "message"
}
Message from the user:
{
"channelData": {
"clientActivityID": "15532464069120.36lccv6nsg3",
"state": "sent"
},
"channelId": "emulator",
"conversation": {
"id": "a10fba20-4c83-11e9-b1fa-8b3537dcca45|livechat"
},
"entities": [
{
"requiresBotState": true,
"supportsListening": true,
"supportsTts": true,
"type": "ClientCapabilities"
}
],
"from": {
"id": "r_xl9pb24o5o",
"name": "User",
"role": "user"
},
"id": "aed62f90-4c83-11e9-98ea-9595460a8f6e",
"localTimestamp": "2019-03-22T11:20:06+02:00",
"locale": "",
"recipient": {
"id": "2",
"name": "Bot",
"role": "bot"
},
"serviceUrl": "http://localhost:53634",
"showInInspector": true,
"text": "hi",
"textFormat": "plain",
"timestamp": "2019-03-22T09:20:06.921Z",
"type": "message"
}
This was a bug in the Emulator, and fixed with https://github.com/Microsoft/BotFramework-Emulator/pull/1348
Please make sure you are on version >= 4.3.3:
Also, the Recipient.Id is the bot id if the message is coming from the Emulator.
Being that the bots do not track or identify a user, that part is up to you.
You will need to:
Create a "back channel" that captures Authentication of user. Give the bot access to the userid/username of the user who is interacting or having a conversation.
When the user logs in and authenticates to the application, you identify the user - retrieve this.
When the user interacts with the bot you get the conversation ID - you already have this.
Tie them together in a JSON object and store back to cloud storage, or app storage or SQL db.
Below is my json which I need to process using jq in bash script. I need to get the "Id" column value. Since in this json there are 3 records, record with maximum value id would be returned. So after processing of below json I should get 170.
I am newbie and have very limited exposure to bash.
{
"count": 3,
"value": [
{
"properties": {},
"tags": [], "validationResults": [],
"plans": [
{
"planId": "49699e0f-b893-4633-bc05-754b8a562d07"
}
], "triggerInfo": {},
"id": 170,
"buildNumber": "20181011.8", "status": "completed", "result": "succeeded", "queueTime": "2018-10-11T15:56:24.9611153Z", "startTime": "2018-10-11T15:56:28.3668144Z", "finishTime": "2018-10-11T15:57:20.5163422Z",
"url": "https://indiatelecom.visualstudio.com/d354caa2-2e88-414a-829b-25df3aceaaaf/_apis/build/Builds/170",
"buildNumberRevision": 8, "uri": "vstfs:///Build/Build/170",
"sourceBranch": "refs/heads/master", "sourceVersion": "4303c19f8fda79e35fcb598219d5dca6bb274c2d",
"priority": "normal", "reason": "manual", "lastChangedDate": "2018-10-11T15:57:20.797Z", "parameters": "{\"system.debug\":\"false\"}",
"orchestrationPlan": {
"planId": "49699e0f-b893-4633-bc05-754b8a562d07"
}, "keepForever": false, "retainedByRelease": false, "triggeredByBuild": null
},
{ "properties": {}, "tags": [], "validationResults": [],
"plans": [ { "planId": "15026a2f-c725-4e52-974b-61e01a940661"
} ],
"triggerInfo": {},
"id": 160,
"buildNumber": "20181009.20", "status": "completed", "result": "succeeded", "queueTime": "2018-10-09T16:47:42.2954075Z", "startTime": "2018-10-09T16:47:43.8034575Z",
"finishTime": "2018-10-09T16:48:35.8340469Z", "url": "https://indiatelecom.visualstudio.com/d354caa2-2e88-414a-829b-25df3aceaaaf/_apis/build/Builds/160",
"buildNumberRevision": 20, "uri": "vstfs:///Build/Build/160",
"sourceBranch": "refs/heads/master", "sourceVersion": "19a55c7482083785265b86015150521b40230c11",
"priority": "normal", "reason": "manual",
"lastChangedDate": "2018-10-09T16:48:36.057Z", "parameters": "{\"system.debug\":\"false\"}",
"orchestrationPlan": {
"planId": "15026a2f-c725-4e52-974b-61e01a940661"
},
"keepForever": false, "retainedByRelease": false,
"triggeredByBuild": null },
{
"properties": {}, "tags": [],
"validationResults": [], "plans": [
{
"planId": "e45d9da8-4d95-42b7-aa23-478e1c1c49f5"
}
],
"triggerInfo": {},
"id": 147,
"buildNumber": "20181009.7", "status": "completed",
"result": "succeeded", "queueTime": "2018-10-09T15:15:47.0248009Z",
"startTime": "2018-10-09T15:15:50.8899892Z", "finishTime": "2018-10-09T15:16:47.7866356Z",
"url": "https://indiatelecom.visualstudio.com/d354caa2-2e88-414a-829b-25df3aceaaaf/_apis/build/Builds/147",
"buildNumberRevision": 7, "uri": "vstfs:///Build/Build/147",
"sourceBranch": "refs/heads/master", "sourceVersion": "70fccb138a2f2a9dfe18290c468959102f504067",
"priority": "normal", "reason": "manual",
"lastChangedDate": "2018-10-09T15:16:48.16Z",
"parameters": "{\"system.debug\":\"false\"}", "orchestrationPlan": {
"planId": "e45d9da8-4d95-42b7-aa23-478e1c1c49f5"
}, "keepForever": false, "retainedByRelease": false,
"triggeredByBuild": null }
] }
The id's are stored in an array under the key value. .value[].id lists the ids, if you put them into an array, you can call max on it:
jq '[.value[].id] | max' < file.json
I have created a Logic App in Azure which works fine in Azure itself. So I first recreated the Logic App within VS2017 (with "Azure Logic Apps for Visual Studio" extension installed). The logic app contains a trigger to read from the Azure Servicebus and calls a custom logic app connector action. This custom connector calls a SOAP webservice via an Azure Data Gateway, which runs fine.
Now the issue is that when I try to deploy it from VS2017, it complains in the Output window. The message I get is:
New-AzureRmResourceGroupDeployment : 13:41:34 - Resource MICROSOFT.WEB/CONNECTIONS 'MyCustomConnector' failed with message '{"error": {"code": "ConnectionGatewayFailure","message": "Establishing connection with the service failed with code 'BadRequest'."}}'
My Logic App works great because I receive the SOAP request in my on-premise application.
What I have tried so far:
Checked my permissions, I am now owner of the resource groups (one where the Logic App and custom connector resides in, and one where the Gateway resides in)
Copied content in: "My resource group > Settings > Automation script > Json Template" and pasted it into Visual Studio
Run Visual Studio as Administrator
Added "-DeploymentDebugLogLevel All" to my Deploy-AzureResourceGroup.ps1 file, doesn't show me anything more useful.
Troubleshoot common Azure deployment errors which says for BadRequest: "You sent deployment values that do not match what is expected by Resource Manager. Check the inner status message for help with troubleshooting." I see no inner status message.
Checked Google for a useful answer
But up until now, without success. So hopefully some of you can help me.
Edit: Here's my ARM template, I renamed a few things, hopefully not too much.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"connections_servicebus_name": {
"defaultValue": "servicebus",
"type": "String"
},
"customApis_MyCustomConnector_name": {
"defaultValue": "My-Custom-Connector",
"type": "String"
},
"connections_MyCustomConnector_name": {
"defaultValue": "My-Custom-Connector",
"type": "String"
},
"workflows_MyLogicApp_name": {
"defaultValue": "My-LogicApp",
"type": "String"
},
"workflows_MyLogicApp_id": {
"defaultValue": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Logic/integrationAccounts/My-Integration-Account",
"type": "String"
}
},
"variables": {},
"resources": [
{
"comments": "Generalized from resource: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup-B/providers/Microsoft.Logic/workflows/My-LogicApp'.",
"type": "Microsoft.Logic/workflows",
"name": "[parameters('workflows_MyLogicApp_name')]",
"apiVersion": "2017-07-01",
"location": "westeurope",
"tags": {},
"scale": null,
"properties": {
"state": "Enabled",
"integrationAccount": {
"id": "[parameters('workflows_MyLogicApp_id')]"
},
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
},
"actions": {
},
"outputs": {}
},
"parameters": {
"$connections": {
"value": {
"My-Custom-Connector": {
"connectionId": "[resourceId('Microsoft.Web/connections', parameters('connections_MyCustomConnector_name'))]",
"connectionName": "My-Custom-Connector",
"id": "[resourceId('Microsoft.Web/customApis', parameters('customApis_MyCustomConnector_name'))]"
},
"servicebus": {
"connectionId": "[resourceId('Microsoft.Web/connections', parameters('connections_servicebus_name'))]",
"connectionName": "servicebus",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Web/locations/westeurope/managedApis/servicebus"
}
}
}
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/connections', parameters('connections_MyCustomConnector_name'))]",
"[resourceId('Microsoft.Web/customApis', parameters('customApis_MyCustomConnector_name'))]",
"[resourceId('Microsoft.Web/connections', parameters('connections_servicebus_name'))]"
]
},
{
"comments": "Generalized from resource: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup-B/providers/Microsoft.Web/connections/My-Custom-Connector'.",
"type": "Microsoft.Web/connections",
"name": "[parameters('connections_MyCustomConnector_name')]",
"apiVersion": "2016-06-01",
"location": "westeurope",
"scale": null,
"properties": {
"displayName": "LogicAppsCustomConnector-Connection",
"customParameterValues": {},
"api": {
"id": "[resourceId('Microsoft.Web/customApis', parameters('customApis_MyCustomConnector_name'))]"
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/customApis', parameters('customApis_MyCustomConnector_name'))]"
]
},
{
"comments": "Generalized from resource: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup-B/providers/Microsoft.Web/connections/servicebus'.",
"type": "Microsoft.Web/connections",
"name": "[parameters('connections_servicebus_name')]",
"apiVersion": "2016-06-01",
"location": "westeurope",
"scale": null,
"properties": {
"displayName": "worker_outbound",
"customParameterValues": {},
"api": {
"id": "[concat('/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Web/locations/westeurope/managedApis/', parameters('connections_servicebus_name'))]"
}
},
"dependsOn": []
},
{
"comments": "Generalized from resource: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup-B/providers/Microsoft.Web/customApis/My-Custom-Connector'.",
"type": "Microsoft.Web/customApis",
"name": "[parameters('customApis_MyCustomConnector_name')]",
"apiVersion": "2016-06-01",
"location": "westeurope",
"scale": null,
"properties": {
"connectionParameters": {
"authType": {
"type": "string",
"allowedValues": [
{
"value": "none"
}
],
"uiDefinition": {
"displayName": "Authentication Type",
"description": "Authentication type to connect to your API",
"tooltip": "Authentication type to connect to your API",
"constraints": {
"tabIndex": 1,
"required": "true",
"allowedValues": [
{
"text": "none",
"value": "anonymous"
}
],
"capability": [
"gateway"
]
}
}
},
"gateway": {
"type": "gatewaySetting",
"gatewaySettings": {
"dataSourceType": "CustomConnector",
"connectionDetails": []
},
"uiDefinition": {
"constraints": {
"tabIndex": 4,
"required": "true",
"capability": [
"gateway"
]
}
}
}
},
"brandColor": "#ffffff",
"description": "Calls My SOAP test webservice.",
"displayName": "[parameters('customApis_MyCustomConnector_name')]",
"iconUri":
},
"dependsOn": []
}
]
}
Messages delivered from Bot Framework don't have name property in from object if message was sent by user who doesn't have username and full name. For example if you delete first or last name from profile like that
Here's example of json that I get for messages sent from user that only has first name (look at from object):
{
"channelData": {
"message": {
"chat": {
"all_members_are_administrators": true,
"id": -219911672,
"title": "jlarky-dev",
"type": "group"
},
"date": 1493246056,
"from": {
"first_name": "Test",
"id": 107390199
},
"message_id": 100,
"text": "test"
},
"update_id": 66470785
},
"channelId": "telegram",
"conversation": {
"id": "-219911672",
"isGroup": true,
"name": "jlarky-dev"
},
"entities": [
{
"mentioned": {
"id": "JLarkyTestBot",
"name": "jlarky_test"
},
"text": "JLarkyTestBot",
"type": "mention"
}
],
"from": {
"id": "107390199"
},
"id": "KxBlE8JsLfg",
"recipient": {
"id": "JLarkyTestBot",
"name": "jlarky_test"
},
"serviceUrl": "https://telegram.botframework.com",
"text": "test",
"timestamp": "2017-04-26T22:34:17.4109674Z",
"type": "message"
}
Since #NilsW's comment I tested this again and it looks like from.name only exists when username of telegram profile was set (same can be looked up from channelData.message.from.username), so I guess it makes sense for it not to show username when username was not set :) and not having last_name part was not related here.
I am writing a wrapper to retrive transaction data for the Square Connect API V2. I am able to retrive the trasactions with Order data missing.
I am getting following response using All Transaction and Retrieve Transaction API:
{
"transactions": [
{
"id": "mYziFkYv2QK7e2kb2vyIhegeV",
"location_id": "75S3K9Z9KSVYK",
"created_at": "2017-04-17T11:00:51Z",
"tenders": [
{
"id": "2qeDw6CmCs299m9w0RY7KQB",
"location_id": "75S3K9Z9KSVYK",
"transaction_id": "mYziFkYv2QK7e2kb2vyIhegeV",
"created_at": "2017-04-17T11:00:51Z",
"amount_money": {
"amount": 10000,
"currency": "INR"
},
"processing_fee_money": {
"amount": 0,
"currency": "INR"
},
"type": "OTHER"
}
],
"product": "REGISTER",
"client_id": "75S3K9Z9KSVYK-a776-4377-84f5-75S3K9Z9KSVYK"
},
{
"id": "UJsg9IdIv9WWvqT1h2VkbxgeV",
"location_id": "75S3K9Z9KSVYK",
"created_at": "2017-04-17T11:00:37Z",
"tenders": [
{
"id": "UVuQghb8RTF8OUcmAsaXKQB",
"location_id": "75S3K9Z9KSVYK",
"transaction_id": "UJsg9IdIv9WWvqT1h2VkbxgeV",
"created_at": "2017-04-17T11:00:37Z",
"amount_money": {
"amount": 0,
"currency": "INR"
},
"processing_fee_money": {
"amount": 0,
"currency": "INR"
},
"type": "NO_SALE"
}
],
"product": "REGISTER",
"client_id": "75S3K9Z9KSVYK-a751-4434-a041-75S3K9Z9KSVYK"
}
]}
Is there any way to get order (line item) details?
If you are looking for itemizations, you can use the v1 transactions endpoints.
See here: https://docs.connect.squareup.com/api/connect/v1/#get-paymentid