Azure Devops API Release definitions expand recursively (I need workflowTasksfrom deployPhases from environments) - api

Does the Azure Devops REST API allow me to expand multiple levels? When using the release definitions I specifically need the workflowtasks, which are buried a couple of lists deep.
More context:
I'm optimizing an Azure Devops extension that scans pipelines for compliancy. Right now there's a rule that scans the workflowtasks. To get the information required on all relevant pipelines, we do the following call to the Azdo API for each release definition:
https://vsrm.dev.azure.com/{Organization}/{Project}/_apis/release/definitions/{definitionID}?api-version=6.0
This returns a completely decked-out release definition including environments like this:
"environments": [{
"id": 10,
"name": "Stage 1",
... etc
"deployPhases": [{
"deploymentInput": {
"parallelExecution": {
"parallelExecutionType": "none"
},
...etc
"rank": 1,
...etc
"workflowTasks": [{
"environment": {},
"taskId": "obfuscated",
"version": "2.*",
"name": "obfuscated",
"refName": "",
"enabled": true,
"alwaysRun": false,
"continueOnError": false,
"timeoutInMinutes": 0,
"retryCountOnTaskFailure": 0,
"definitionType": "task",
"overrideInputs": {},
"condition": "succeeded()",
"inputs": {
"template": "obfuscated",
"assets": "obfuscated",
"duration": "60",
"title": "",
"description": "",
"implementationPlan": "obfuscated"
}
}, {
"environment": {},
"taskId": "obfuscated",
"version": "2.*",
"name": "obfuscated",
"refName": "",
"enabled": true,
"alwaysRun": false,
"continueOnError": false,
"timeoutInMinutes": 0,
"retryCountOnTaskFailure": 0,
"definitionType": "task",
"overrideInputs": {},
"condition": "succeeded()",
"inputs": {
"changeClosureCode": "1",
"changeClosureComments": "Successful implementation",
"changeId": ""
}
}
]
}
],
...etc
}
],
But when I try and get the list as a whole, using the following URL:
https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions?$expand=environments&api-version=6.0
My Environments arrays (there is one for each definition obviously) looks nothing like the previous one. It doesn't include deployPhases (not even as an empty array).
Since we have 2300 release definitions, you can Imagine how inconvenient it is to call the release/definitions/{definitionID} endpoint instead of the release/definitions one that fetches all of them at the same time.
Is there a way to expand the release/definitions call to fetch all environments including workflowTasks and maybe other stuff? Is there a syntax that allows for this? Something like $expand=environments>deployPhases>workflowTasks?

Is there a way to expand the release/definitions call to fetch all environments including workflowTasks and maybe other stuff? Is there a syntax that allows for this? Something like $expand=environments>deployPhases>workflowTasks?
I am afraid there is no such syntax allow you to fetch all environments including workflowTasks.
You could use the REST API with some powershell scripts to fetch all environments including workflowTasks:
The sample powershell scripts:
$url = "https://vsrm.dev.azure.com/{Organization}/{Project}/_apis/release/definitions/{definitionID}?api-version=6.0"
Write-Host "URL: $url"
$pipeline = Invoke-RestMethod -Uri $url -Method Get -Headers #{
Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"
}
Write-Host "workflowTasks = $($pipeline.environments.deployPhases.workflowTasks | ConvertTo-Json -Depth 100)"
The output is:

Related

How can i custom config CHANGELOG.md using standard-version npm package?

I'm using the command standard-version each time I want to publish new version, but the yielded changes in the CHANGELOG.md look like this:
### [10.1.9](https://github.com/my-project-name/compare/v10.1.8...v10.1.9) (2021-03-29)
### [10.1.8](https://github.com/my-project-name/compare/v10.1.7...v10.1.8) (2021-03-29)
### [10.1.7](https://github.com/my-project-name/compare/v10.1.6...v10.1.7) (2021-03-29)
first the links do not work - the github url is not correct and i want to configure it to the right url, and second, I'd like to configure the link that's shown in the changeslog file (there are some types)
I tried to use this documentation but didn't find anything that can help me
https://github.com/conventional-changelog/conventional-changelog
so how do I configure the way standard-version works on the CHANGELOG.md ? can someone provide example?
yes.
according to doc:
You can configure standard-version either by:
Placing a standard-version stanza in your package.json (assuming your project is JavaScript).
Creating a .versionrc, .versionrc.json or .versionrc.js.
If you are using a .versionrc.js your default export must be a configuration object, or a function returning a configuration object.
Any of the command line parameters accepted by standard-version can instead be provided via configuration.
Please refer to the conventional-changelog-config-spec for details on available configuration options.
example:
.versionrc
{
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "chore",
"hidden": true
},
{
"type": "docs",
"hidden": true
},
{
"type": "style",
"hidden": true
},
{
"type": "refactor",
"section": "Refactor"
},
{
"type": "perf",
"section": "Performance"
},
{
"type": "test",
"hidden": true
}
]
}

Why is "create" undefined for Edge extension notifications?

Running code in Edge extension throws a TypeError, unable to get property 'create' of undefined or null reference.
I have tried running it in both the popup and background scripts. I have the notifications permissions in the manifest. I did see that some APIs require being run in the content script, but since I'm not engaging the tabs or web pages, I don't think that applies to me...?
Manifest:
{
"name": "xxx",
"author": "xxx", "version": "1.1",
"options_page": "options.html",
"background": {
"scripts": ["jquery-3.3.1.min.js","background.js"], "persistent": true
},
"permissions": [
"xxx",
"background",
"notifications",
"storage"
],
"offline_enabled": true,
"browser_action": {
"default_title": "xxx",
"default_popup": "popup.html",
"default_icon": "32.png"
},
"manifest_version": 2
}
Background script:
try{
browser.notifications.create("test",{
"type": "basic",
"title": "Test",
"iconUrl": "48.png",
"message": "This is a test"
});
}catch(e){
alert(e);
}
Based on your description, first, you could try to upgrade the Edge browser to the latest version, then, try to use the browser.notifications.create method.
But, in my opinion, I prefer to display the notification using the Web Notifications API, you could check this article.

Ruckus SmartZone API

I am having issues when trying to create a Zone using the API.
I can create the zone with the basic info, but as soon as I want to add another property (specifically "location") I get an error.
This is my dataset I use for the POST
def id_prov ={
"domainId": "$DomainId",
"name": "$ZoneName",
"login": {
"apLoginName": "xxxxx",
"apLoginPassword": "xxxxx"
},
"description": "$jira_summ",
"version": "3.5.1.0.1010",
"countryCode": "ZA"
"location": "$CalledStationName_val",
}
The API creates everything until I either include the "location" property in the original POST or if I try a PUT or PATCH atferwards.
Result value:
{"message":["object instance has properties which are not allowed by the schema: [\"location\"]"],"errorCode":101,"errorType":"Bad HTTP request"}
Anyone come across this or have any ideas on how to get this working?
Thanks
A comma is required after "countryCode": "ZA". The post payload should look like this:
def id_prov ={
"domainId": "$DomainId",
"name": "$ZoneName",
"login": {
"apLoginName": "xxxxx",
"apLoginPassword": "xxxxx"
},
"description": "$jira_summ",
"version": "3.5.1.0.1010",
"countryCode": "ZA",
"location": "$CalledStationName_val",
}

HERE Places API: not all items have PVID

I'm using HERE Places API.
Firstly I'm doing a search.
For Example this query :
https://places.cit.api.here.com/places/v1/discover/search?q=Test&at=35.6111,-97.5467&r=500&size=1&app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg&show_refs=pvid&pretty
According to this documentation (Link) If I add show_refs=pvid to query string, in result I will get external id which I can use to query lookup endpoint.
But in result I get next response :
{
"results": {
"next": "https://places.cit.api.here.com/places/v1/discover/search;context=Zmxvdy1pZD1hY2ExNzk3NC0zYzg3LTU5NzQtYmZkMC04YjAzMDZlYWIzMWJfMTUwNjA3NjMzMTYyMl83NDY3XzM4NTAmb2Zmc2V0PTEmc2l6ZT0x?at=35.6111%2C-97.5467&q=Test&app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg",
"items": [
{
"position": [
35.60369,
-97.51761
],
"distance": 2756,
"title": "Southwest Test & Balance",
"averageRating": 0,
"category": {
"id": "business-services",
"title": "Business & Services",
"href": "https://places.cit.api.here.com/places/v1/categories/places/business-services?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg",
"type": "urn:nlp-types:category",
"system": "places"
},
"icon": "https://download.vcdn.cit.data.here.com/p/d/places2_stg/icons/categories/02.icon",
"vicinity": "200 NW 132nd St<br/>Oklahoma City, OK 73114",
"having": [],
"type": "urn:nlp-types:place",
"href": "https://places.cit.api.here.com/places/v1/places/8403fv6k-d1b2fde0616e0326e321a54b88cd9f53;context=Zmxvdy1pZD1hY2ExNzk3NC0zYzg3LTU5NzQtYmZkMC04YjAzMDZlYWIzMWJfMTUwNjA3NjMzMTYyMl83NDY3XzM4NTAmcmFuaz0w?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg",
"id": "8403fv6k-d1b2fde0616e0326e321a54b88cd9f53",
"authoritative": true
}
]
},
"search": {
"context": {
"location": {
"position": [
35.6111,
-97.5467
],
"address": {
"text": "Oklahoma City, OK 73134<br/>USA",
"postalCode": "73134",
"city": "Oklahoma City",
"county": "Oklahoma",
"stateCode": "OK",
"country": "United States",
"countryCode": "USA"
}
},
"type": "urn:nlp-types:place",
"href": "https://places.cit.api.here.com/places/v1/places/loc-dmVyc2lvbj0xO3RpdGxlPU9rbGFob21hK0NpdHk7bGF0PTM1LjYxMTE7bG9uPS05Ny41NDY3O2NpdHk9T2tsYWhvbWErQ2l0eTtwb3N0YWxDb2RlPTczMTM0O2NvdW50cnk9VVNBO3N0YXRlQ29kZT1PSztjb3VudHk9T2tsYWhvbWE7Y2F0ZWdvcnlJZD1jaXR5LXRvd24tdmlsbGFnZTtzb3VyY2VTeXN0ZW09aW50ZXJuYWw;context=c2VhcmNoQ29udGV4dD0x?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg"
}
}
}
In response no object references
Is it a bug or not every place has this external id?
I am responding as member of the team around HERE Places API.
Yes, not every place has a pvid. That is why I would suggest using the Sharing Id instead. I realize that the documentation should be improved to clarify that.
The Sharing Ids can be obtained by adding show_refs=sharing to either your search query or a place details request. It can be found in the field references. Once you have the sharing id you can you the lookup endpoint as you intended.
Take a look at:
https://places.cit.api.here.com/places/v1/places/8403fv6k-d1b2fde0616e0326e321a54b88cd9f53;context=Zmxvdy1pZD00YWU2ZWZjNi01ZjgzLTUwYTQtOTI4OS0xZjliMGMwNWY3NjBfMTUwNzA0NDE0OTc3NV84MTI5XzU1NDcmcmFuaz0w?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg&show_refs=pvid
and
https://places.cit.api.here.com/places/v1/places/8409q8yy-6af3c3e50bcb4f859686797b2be5773d;context=Zmxvdy1pZD00YWU2ZWZjNi01ZjgzLTUwYTQtOTI4OS0xZjliMGMwNWY3NjBfMTUwNzA0NDE0OTc3NV84MTI5XzU1NDcmcmFuaz0w?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg&show_refs=pvid
On those two examples, the only difference is the placeId.
In the docs, there's not a single reference saying that the external identifier is required or existant for every place.
Since it represents an external identifier, I believe we could assume that it's not required.
And it's what we just saw with your place (8403fv6k-d1b2fde0616e0326e321a54b88cd9f53): this one don't have any external identifier.
Based on your comments, what you need is the information about a place.
So, after you run your first query, you should get something like:
{
title: "Southwest Test & Balance",
position: [],
id: "8403fv6k-d1b2fde0616e0326e321a54b88cd9f53",
href: "https://[...]"
}
With this ID, you could access it:
places.cit.api.here.com/places/v1/places/8403fv6k-d1b2fde0616e0326e321a54b88cd9f53;context=Zmxvdy1pZD0zYTFlZjg5ZS02ZTY5LTUxYmEtYWFkYS1kY2UwZWMyNDdkMDBfMTUwNzEzNjUxNjI5N182NjExXzc2OTgmcmFuaz0w?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg
Or directly using the href information.
This response already is giving you the ID and URL to access all the info of a single place.
You don't need any other external ID or reference.

ARM - How can I get the access key from a storage account to use in AppSettings later in the template?

I'm creating an Azure Resource Manager template that instantiates multiple resources, including an Azure storage account and an Azure App Service with a Web App.
I'd like to be able to capture the primary access key (or the full connection string, either way is fine) from the newly-created storage account, and use that as a value for one of the AppSettings for the Web App.
Is that possible?
Use the listkeys helper function.
"appSettings": [
{
"name": "STORAGE_KEY",
"value": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value]"
}
]
This quickstart does something similar:
https://azure.microsoft.com/en-us/documentation/articles/cache-web-app-arm-with-redis-cache-provision/
The syntax has changed since the other answer was accepted. The error you will now hit is 'Template language expression property 'key1' doesn't exist, available properties are 'keys'
Keys are now represented as an array of keys, and the syntax is now:
"StorageAccount": "[Concat('DefaultEndpointsProtocol=https;AccountName=',variables('StorageAccountName'),';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('StorageAccountName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value)]",
See: http://samcogan.com/retrieve-azure-storage-key-in-arm-script/
I faced with this issue two times. First in the 2015 and last today in May of 2017.
I need to add connection strings to the WebApp - I want to add strings automatically from generated resources during deployment from the ARM template. It can help later to not add manually this values.
First time I used old version of the function listKeys (it looks like old version returns result not as object but as value):
"AzureWebJobsStorage": {
"type": "Custom",
"value": "[concat(variables('storageConnectionString'), listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2015-05-01-preview').key1)]"
},
Today last version of the working template is:
"resources": [
{
"apiVersion": "2015-08-01",
"type": "config",
"name": "connectionstrings",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites/', parameters('webSiteName'))]"
],
"properties": {
"DefaultConnection": {
"value": "[concat('Data Source=tcp:', reference(resourceId('Microsoft.Sql/servers/', parameters('sqlserverName'))).fullyQualifiedDomainName, ',1433;Initial Catalog=', parameters('databaseName'), ';User Id=', parameters('administratorLogin'), '#', parameters('sqlserverName'), ';Password=', parameters('administratorLoginPassword'), ';')]",
"type": "SQLServer"
},
"AzureWebJobsStorage": {
"type": "Custom",
"value": "[concat(variables('storageConnectionString'), listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageName')), '2016-01-01').keys[0].value)]"
},
"AzureWebJobsDashboard": {
"type": "Custom",
"value": "[concat(variables('storageConnectionString'), listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageName')), '2016-01-01').keys[0].value)]"
}
}
},
Thanks.
below is example for adding storage account to ADLA
"storageAccounts": [
{
"name": "[parameters('DataLakeAnalyticsStorageAccountname')]",
"properties": {
"accessKey": "[listKeys(variables('storageAccountid'),'2015-05-01-preview').key1]"
}
}
],
in variable you can keep
"variables": {
"apiVersion": "[providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]]",
"storageAccountid": "[concat(resourceGroup().id,'/providers/','Microsoft.Storage/storageAccounts/', parameters('DataLakeAnalyticsStorageAccountname'))]"
},