RequireJS script error when requiring "ReleaseaManagement/Core/RestClient" on TFS 2015 and 2017 - tfs-2015

I'm creating an tfs hub Extension (2015/2017) and need to read the projects' release defs and create releases also. I know, I could make direkt Rest Calls instead of using the methods of the rest clients. But they seem more comfortable to me.
When I try to get the Restmanagement RestClient, I get:
Script error for: ReleaseManagement/Core/RestClient
http://requirejs.org/docs/errors.html#scripterror
In both TFS.2015.2 and TFS.2017
Doesn't the client yet exist on-premise?

You can refer to this article for how to use Rest API in extension to read a release definition: Writing a ReleaseManagement extension for cloning an existing release definition.
The code to read a release definition:
VSS.require(["VSS/Controls", "VSS/Service", "ReleaseManagement/Core/RestClient"],
var rmClient = VSS_Service.getCollectionClient(RM_WebApi.ReleaseHttpClient);
rmClient.getReleaseDefinition(vsoContext.project.id,sourceItemContext.definition.id);
And if you are using typescript, you need to include "ms.vss-releaseManagement-web.release-service-data-external" in the contribution like following:
"contributions": [
{
"id": "release-status",
"type": "ms.vss-web.hub",
"includes": [ "ms.vss-releaseManagement-web.release-service-data-external" ],
"description": "A hub to show release status",
"targets": [
"ms.vss-work-web.work-hub-group"
],
"properties": {
"name": "hello",
"order": 99,
"uri": "app.html"
}
}
]

Related

How do I make APIManagement Service Logger deploy before the Application insights Resource?

I am trying to make the following ARM deploy a APIM service logger, however the service logger starts to deploy before the app insights resource and fails, the app insights resource is in a seperate template. I have added a dependson statement and thought that would do the job but that did'nt work either. Also the code below actually works if the app insights is already deployed.
does anyone have any pointers?
{
"type": "Microsoft.ApiManagement/service/loggers",
"name": "[concat(variables('apiManagementInstanceName'), '/', parameters('appInsightsName'))]",
"apiVersion": "2018-01-01",
"properties": {
"loggerType": "applicationInsights",
"description": "Logger resources to APIM",
"credentials": {
"instrumentationKey": "[reference(resourceId('Microsoft.Insights/components', parameters('appInsightsName')), '2015-05-01').InstrumentationKey]"
}
}
"dependsOn": [
"[resourceId('microsoft.insights/components', parameters('appInsightsName'))]"
]
}
also tried depending on both the APIM and app insights
"dependsOn": [
//"[resourceId('Microsoft.ApiManagement/service', variables('apiManagementInstanceName'))]"
"[resourceId('microsoft.insights/components', parameters('appInsightsName'))]"
],
You can use linked templates to reference another template file and define dependencies on it: https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/linked-templates#linked-template

Query TFS to show all releases and whether or not it is set for approval. V 2017.3

I need to run a query in sql that will show all the TFS releases from all projects and whether or not it is setup for pre relase approvals. I see in the defaultcollection db there is the Release.tbl_ReleaseDefinition table, it has a lot of data but not approval info. I do see the Release.tbl_DefinitionEnvironment and I see ApprovalOptions there, but that seems to be showing the approval info for every release created whereas I am needing info on release definitions only.
Just as Daniel pointed out, we highly not recommend you dig into TFS databased directly.
According to your description, you just need the approval info for all release definitions. Suggest you use Rest API to handle this.
For a single release, you could use below Rest API:
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions/{definitionId}?api-version=5.1
It will return both preDeployApprovals and postDeployApprovals, for example:
"preDeployApprovals": {
"approvals": [
{
"rank": 1,
"isAutomated": false,
"isNotificationOn": false,
"approver": {
"displayName": "Chuck Reinhart",
"url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/aeb95c63-4fac-4948-84ce-711b0a9dda97",
"_links": {
"avatar": {
"href": "https://dev.azure.com/fabrikam/_apis/GraphProfile/MemberAvatars/aad.YjYxMjE5ZWQtODEwYS03OTU3LWJjYzAtMjQ0YTI5ZDk0ZjFl"
}
},
"id": "aeb95c63-4fac-4948-84ce-711b0a9dda97",
"uniqueName": "fabfiber#outlook.com",
"imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=aeb95c63-4fac-4948-84ce-711b0a9dda97",
"descriptor": "aad.YjYxMjE5ZWQtODEwYS03OTU3LWJjYzAtMjQ0YTI5ZDk0ZjFl"
},
"id": 118
}
],
More details please take a look at official doc here: Definitions - Get
For multiple release, you should use list: Definitions - List
Hope this helps.

How do I automate adding a custom Iot Hub Endpoint (and route to it)?

In order to receive Azure IotHub Device Twin change notifications, it appears that it's necessary to create a custom endpoint and create a route to send notifications to that endpoint. This seems straightforward enough on the Azure Portal, but as one might expect we want to automate it.
I haven't been able to find any documentation for the the az cli or even the REST API, though I might have missed something. I didn't find anything promising looking in the SDKs either.
How do I automate adding a custom endpoint and then setting up the route for device twin notifications?
You can check IotHubs template to see if it helps.
Route:
"routing": {
"endpoints": {
"serviceBusQueues": [
{
"connectionString": "string",
"name": "string",
"subscriptionId": "string",
"resourceGroup": "string"
}
]
},
"routes": [
{
"name": "string",
"source": "string",
"condition": "string",
"endpointNames": [
"string"
],
"isEnabled": boolean
}
],
Consumer group:
{
"apiVersion": "2016-02-03",
"type": "Microsoft.Devices/IotHubs/eventhubEndpoints/ConsumerGroups",
"name": "[concat(parameters('hubName'), '/events/cg1')]",
"dependsOn": [
"[concat('Microsoft.Devices/Iothubs/', parameters('hubName'))]"
]
},
For more detailed information you can reference:
Microsoft.Devices/IotHubs template reference
Create an IoT hub using Azure Resource Manager template (PowerShell)

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'))]"
},

Xbmc Database Path

I am working with XBMC. I have installed XBMC in my system(Windows 7, 32 bit). Xbmc is working fine in my system. I have developed an application in order to control the Xbmc remotely from Ipad. In order to retrieve the music files or video files from Xbmc, I am unable to. By searching the forums of xbmc, I found that we can write an sql query to get them out. But, the thing is I am unable to make out where the database is located in my system. Someone help me out where I can find it.
Regards,
Sushma.
The database itself
By default the location of the database is that described on the wiki page XBMC databases
but the actual location can be changed by the user, or a different database technology can be used entirely.
The settings that would affect this are located in advancedsettings.xml.
But in general it is advised by the XBMC developers to never access the database directly.
JSONRPC
In order to help with interacting with the database XBMC has supported the JSONRPC queries, the one downside of these is that XBMC needs to be running at the time to respond to these queries. The major advantage is that it XBMC will find the database for you and expose access to it with a common interface.
JSONRPC support was first added to XBMC in "Darhma" (v10), became really useful in "Eden" (v11) and will support almost everything possible in "Frodo" (v12). Information about the use of JSONRPC can be found in the wiki.
An example
In this example I'm assuming that you are targeting "Eden", the current stable release of XBMC. Also I have formatted the following with new lines, these are not required and are not present in the response from XBMC.
Request
If you were to use JSONRPC the request you would need to send would look something like:
{
"jsonrpc": "2.0",
"method": "VideoLibrary.GetMovies",
"params": {
"properties": [
"title",
"year",
"file"
],
"limits": {
"start": 0,
"end": 2
}
},
"id": 1
}
Note: If you wanted different information about each movie you could use other properties listed here.
*Note: You probably want to omit the "limits" part to get all movies.*
Responce
The response to this would be something like:
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"limits": {
"end": 2,
"start": 0,
"total": 47
},
"movies": [
{
"label": "Label for movie",
"movieid": 1,
"title": "Title of movie",
"year": 2012
},
{
"label": "Label for another movie",
"movieid": 2,
"title": "Title of another movie",
"year": 2010
},
{
"label": "Label for a third movie",
"movieid": 3,
"title": "Title of a third movie",
"year": 2012
}
]
}
}
What to do now?
You have a choice at this point, you can either:
Add "file" to the list of properties, this will return the "file" property, the location of the video file.
Use JSONRPC to tell xbmc to play a movie.
Using this method is best when you don't want to play the file locally (on the iPad) but instead on XBMC.
Playing a movie on XBMC via JSONRPC
This is quite simple, use the "movieid" you received earlier in the following request:
{
"jsonrpc": "2.0",
"method": "Player.Open",
"params": {
"item": {
"movieid": 2
}
},
"id": 1
}
Lastly I would note that there are equivalent commands for TV episodes as shown for movies.