Tuesday, 19 January 2016

Update Script Timeout in MTM Test Settings

You could run into default script timeout of five minutes, while running scripts before running tests using MTM.

image

image

Error    1/19/2016 11:10:39 AM    The setup batch file on agent machine 'vstfs:///LabManagement/TestMachine/19' exceeded the execution timeout period.    vstfs:///LabManagement/TestMachine/19

How to Resolve

To increase this timeout there is no straight forward way using MTM. However update deployment timeout is explained in here, utilizing the tool created by Aseem Bansal. But setting Script timeout not available with this particular tool.

As explained in this MSDN Q&A, I have made changes to the code downloaded from the post here by Aseem Bansal and improved it to enable setting the Script Timeout for test settings. You can download the new utility from Technet Gallery here, and use it as explained below (VS 2013 source code for the tool available here). 

UpdateTestSettings /collection:<ProjectCollectionUri> /teamProject:<ProjectName> /settingsname:<TestSettingsName> [/bucketSize:<value>] [/deploymentTimeout:<value>] [/scriptTimeout:<value>]

Examples:

UpdateTestSettings /collection:http://abc:8080/tfs/DefaultCollection /teamProject:myProject /settingsname:My2_0_App /bucketSize:200 /deploymentTimeout:600000

UpdateTestSettings /collection:http://abc:8080/tfs/DefaultCollection /teamProject:myProject /settingsname:My2_0_App /bucketSize:200 /deploymentTimeout:600000 /scriptTimeout:900000

UpdateTestSettings /collection:http://abc:8080/tfs/DefaultCollection /teamProjec:myProject /settingsname:My2_0_App /scriptTimeout:900000

Utility improved to provide Test Settings infor before and after update.
 image

How the code is modified

You can download the original code for the utility from the link provided in the post here.

image

image

When this is built with VS 2013 there could be below errors if you do not have VS 2010 in your machine.image

With or without having above errors remove the references for TeamFoundation dlls.image

There is no Microsoft.TeamFoundation.dll for VS 2013. Microsoft.TeamFoundation.Common.dll would add all thats is added previously by Microsoft.TeamFoundation.dll. Add the references to Team Foundation dlls.image

Remove “Read only” from all code files downloaded before change framework.image

Set the framework to 4.5 and you can build the code with VS 2013 successflully.image

Replace the code in Program.cs with the below updated Program.cs code.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
// ---------------------------------------------------------------------------
// <copyright file="Program.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
// <summary>
//   Updates the specified properties in the tcm test settings.
// 
//   MTM UI does not expose updation of bunch of test settings properties
//   but the same can be achieved via the TCM APIs. This utility uses those
//   APIs to update the following properties in tcm test settings. 
// 
//   1. Deployment timeout. 
//   2. Bucket size. 
//   3. Apartment state. 
// 
// Introduced ScriptTimeout - Chaminda Chandrasekara 19/01/2016
// </summary>
// ---------------------------------------------------------------------------

using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.TestManagement.Client;
using Microsoft.VisualStudio.TestTools.Common;
using Microsoft.VisualStudio.TestTools.Common.Xml;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Xml;

namespace UpdateTestSettings
{
    class Program
    {
        static void Main(string[] args)
        {
            CommandParameters commandParameters;

            Console.WriteLine();
            Console.WriteLine();

            // Validate the parameters
            ValidateArguments(args, out commandParameters);
            Console.WriteLine("Using parameters: {0}", commandParameters);


            // Connect to the team project. 
            TfsTeamProjectCollection collection = new TfsTeamProjectCollection(new Uri(commandParameters.ProjectCollectionUri));
            TestManagementService tcmService = collection.GetService<TestManagementService>();
            ITestManagementTeamProject teamProject = tcmService.GetTeamProject(commandParameters.ProjectName);
            Console.WriteLine("Connected to the team project {0}.", commandParameters.ProjectName);


            // Find the specified test settings.
            TestRunConfiguration testRunConfiguration = null;
            ITestSettings testSetting = FindTestSettings(commandParameters.TestSettingsName, teamProject, out testRunConfiguration);
            
            // Get ScriptTimeout hidden property info
            PropertyInfo pInfo = testRunConfiguration.GetType().GetProperty("ScriptTimeout", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Instance);
            Console.WriteLine("==============================================================");
            Console.WriteLine("Current TestSettings {0} has bucketSize={1}, deploymentTimeout={2}, scriptTimeout={3}  and ApartmentState={4}.", testSetting.Name, testRunConfiguration.BucketSize, testRunConfiguration.DeploymentTimeout, pInfo.GetValue(testRunConfiguration, null), testRunConfiguration.ApartmentState);
            Console.WriteLine("==============================================================");

            Console.WriteLine("Found the testsettings named {0}.", commandParameters.TestSettingsName);

            // If it is an update command, then update the settings
            if (commandParameters.IsUpdate)
            {
                UpdateTestSettings(testSetting, testRunConfiguration, commandParameters);
                Console.WriteLine("Updated the testsettings.");
                Console.WriteLine();
            }

            // Show the new values to the user
            
            // Reload test configurations after update
            FindTestSettings(commandParameters.TestSettingsName, teamProject, out testRunConfiguration);

            Console.WriteLine("==============================================================");
            Console.WriteLine("Updated TestSettings {0} has bucketSize={1}, deploymentTimeout={2}, scriptTimeout={3}  and ApartmentState={4}.", testSetting.Name, testRunConfiguration.BucketSize, testRunConfiguration.DeploymentTimeout, pInfo.GetValue(testRunConfiguration, null),testRunConfiguration.ApartmentState);
            Console.WriteLine("==============================================================");
        }

        /// <summary>
        /// Update the tcm test settings as per the specified command-line parameters
        /// </summary>
        private static void UpdateTestSettings(ITestSettings testSetting, 
                                               TestRunConfiguration testRunConfiguration, 
                                               CommandParameters commandParameters)
        {
            if (commandParameters.HasBucketSize)
            {
                testRunConfiguration.BucketSize = commandParameters.BucketSize;
            }
            if (commandParameters.HasDeploymentTimeout)
            {
                testRunConfiguration.DeploymentTimeout = commandParameters.DeploymentTimeout; 
            }
            if (commandParameters.HasApartmentState)
            {
                testRunConfiguration.ApartmentState = commandParameters.ApartmentState;
            }
            if (commandParameters.HasScriptTimeout)
            {
                PropertyInfo pInfo = testRunConfiguration.GetType().GetProperty("ScriptTimeout", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Instance);

                pInfo.SetValue(testRunConfiguration, commandParameters.ScriptTimeout, null);
            }

            // Tcm test settings contains the TestRunConfiguration xml which has all the settings information. 
            // During the update, we update the testRunConfiguration xml in the test settings
            //
            XmlElement element = LocalXmlPersistence.SaveTestRunConfiguration(testRunConfiguration);
            testSetting.Settings = element;

            testSetting.Save();
        }


        /// <summary>
        /// Find the parameter test settings on the team project
        /// </summary>
        private static ITestSettings FindTestSettings(string testSettingsName, 
                                                      ITestManagementTeamProject teamProject, 
                                                      out TestRunConfiguration testRunConfiguration)
        {
            Console.WriteLine("Finding the testsettings named {0}.", testSettingsName);
            ITestSettings testSetting = null;
            IEnumerable<ITestSettings> testSettings = teamProject.TestSettings.Query("SELECT * FROM TestSettings");

            StringBuilder availableSettings = new StringBuilder();
            foreach (ITestSettings setting in testSettings)
            {
                if (string.Equals(setting.Name, testSettingsName, StringComparison.OrdinalIgnoreCase))
                {
                    if (!setting.IsAutomated)
                    {
                        Console.Error.WriteLine("Warning!! Ignoring testsettings named {0} (with id {1}) as it is a manual testsettings. You should specify only the automated testsettings.", setting.Name, setting.Id);
                        continue;
                    }

                    testSetting = setting;
                    break;
                }

                // We dont want to pick the manual test settings. 
                if (!setting.IsAutomated)
                {
                    continue;
                }
                else
                {
                    if (availableSettings.Length > 0)
                    {
                        availableSettings.Append(",");
                    }

                    availableSettings.Append("\"");
                    availableSettings.Append(setting.Name);
                    availableSettings.Append("\"");
                }
            }

            // Throw error if setting is not found. 
            //
            if (testSetting == null)
            {
                testRunConfiguration = null;

                if (string.IsNullOrEmpty(availableSettings.ToString()))
                {
                    throw new Exception(string.Format(CultureInfo.InvariantCulture, "No automated testsettings found with name {0}. Additionally there is no automated testsettings available in this project. So create an automated testsettings using 'Microsoft Test Manager' and then try again.", testSettingsName));
                }
                else
                {
                    throw new Exception(string.Format(CultureInfo.InvariantCulture, "No automated testsettings found with name {0}. The available automated testsettings are: {1}", testSettingsName, availableSettings));
                }
            }

            // Load the xml from the txm settings into TestRun configuration
            testRunConfiguration = new TestRunConfiguration(testSetting.Name, "dummy");
            testRunConfiguration.Load(testSetting.Settings, XmlTestStoreParameters.GetParameters());
            testRunConfiguration.Name = testSetting.Name;

            return testSetting;
        }


        /// <summary>
        /// Validate the command-line parameters
        /// </summary>
        private static void ValidateArguments(string[] args, out CommandParameters commandParameters)
        {
            if (args.Contains("?", StringComparer.OrdinalIgnoreCase)
                || args.Contains("/?", StringComparer.OrdinalIgnoreCase))
            {
                ShowHelpMessage();
                Environment.Exit(-1);
            }

            string collectionSwitch = "/collection:";
            string projectSwitch = "/teamProject:";
            string testSettingsSwitch = "/settingsname:";
            string bucketSizeSwitch = "/bucketsize:";
            string deploymentTimeoutSwitch = "/deploymentTimeout:";
            string scriptTimeoutSwitch = "/scriptTimeout:";
            string apartmentStateSwitch = "/apartmentState:";
            

            string projectCollectionUri = null;
            string teamProjectName = null;
            string testSettingsName = null;
            int bucketSize = -1;
            int deploymentTimeout = -1;
            int scriptTimeout = -1;
            ApartmentState apartmentState = ApartmentState.Unknown;

            foreach (string argument in args)
            {
                if (argument.StartsWith(collectionSwitch, StringComparison.OrdinalIgnoreCase))
                {
                    projectCollectionUri = argument.Substring(collectionSwitch.Length);
                }
                else if (argument.StartsWith(projectSwitch, StringComparison.OrdinalIgnoreCase))
                {
                    teamProjectName = argument.Substring(projectSwitch.Length);
                }
                else if (argument.StartsWith(testSettingsSwitch, StringComparison.OrdinalIgnoreCase))
                {
                    testSettingsName = argument.Substring(testSettingsSwitch.Length);
                }
                else if (argument.StartsWith(bucketSizeSwitch, StringComparison.OrdinalIgnoreCase))
                {
                    string bucketSizeValue  = argument.Substring(bucketSizeSwitch.Length);
                    bucketSize = int.Parse(bucketSizeValue);
                }
                else if (argument.StartsWith(deploymentTimeoutSwitch, StringComparison.OrdinalIgnoreCase))
                {
                    string deploymentTimeoutValue = argument.Substring(deploymentTimeoutSwitch.Length);
                    deploymentTimeout = int.Parse(deploymentTimeoutValue);
                }
                else if (argument.StartsWith(scriptTimeoutSwitch, StringComparison.OrdinalIgnoreCase))
                {
                    string scriptTimeoutValue = argument.Substring(scriptTimeoutSwitch.Length);
                    scriptTimeout = int.Parse(scriptTimeoutValue);
                }
                else if (argument.StartsWith(apartmentStateSwitch, StringComparison.OrdinalIgnoreCase))
                {
                    string apartmentStateValue = argument.Substring(apartmentStateSwitch.Length);
                    apartmentState = (ApartmentState)Enum.Parse(typeof(ApartmentState), apartmentStateValue, true);
                }
            }

            bool projectCollectionUriError = false, teamProjectError = false, testSettingsError = false;
            if (string.IsNullOrEmpty(projectCollectionUri))
            {
                projectCollectionUriError = true;
            }
            else if (string.IsNullOrEmpty(teamProjectName))
            {
                teamProjectError = true;
            }
            else if (string.IsNullOrEmpty(testSettingsName))
            {
                testSettingsError = true;
            }

            if (projectCollectionUriError || teamProjectError || testSettingsError)
            {
                if (projectCollectionUriError)
                {
                    Console.Error.WriteLine("ProjectCollectionUri argument is not specified");
                }
                else if (teamProjectError)
                {
                    Console.Error.WriteLine("TeamProjectName argument is not specified");
                }
                else if (testSettingsError)
                {
                    Console.Error.WriteLine("Settingsname argument is not specified");
                }

                ShowHelpMessage();
                Environment.Exit(-1);
            }

            commandParameters = new CommandParameters(projectCollectionUri, teamProjectName, testSettingsName);
            commandParameters.BucketSize = bucketSize;
            commandParameters.DeploymentTimeout = deploymentTimeout;
            commandParameters.ScriptTimeout = scriptTimeout;
            commandParameters.ApartmentState = apartmentState;
        }

        private static void ShowHelpMessage()
        {
            Console.Error.WriteLine("Usage: UpdateTestSettings /collection:<ProjectCollectionUri> /teamProject:<ProjectName> /settingsname:<TestSettingsName> [/bucketSize:<value>] [/deploymentTimeout:<value>] [/apartmentState:<value>]");
            Console.Error.WriteLine();
            Console.Error.WriteLine("Examples:");
            Console.Error.WriteLine("UpdateTestSettings /collection:http://abc:8080/tfs/DefaultCollection /teamProject:myProject /settingsname:My2_0_App /bucketSize:200 /deploymentTimeout:600000 /apartmentState:MTA");
            Console.Error.WriteLine();
            Console.Error.WriteLine("UpdateTestSettings /collection:http://abc:8080/tfs/DefaultCollection /teamProject:myProject /settingsname:My2_0_App");
            Console.Error.WriteLine();
            Console.Error.WriteLine("Default values: BucketSize=100 & DeploymentTimeOut=300000 & ApartmentState=STA.");
        }


    }


    /// <summary>
    /// Helper class to capture the command-line inputs
    /// </summary>
    public class CommandParameters
    {
        private string m_projectCollectionUri;
        private string m_teamProjectName;
        private string m_testSettingsName;

        private int m_bucketSize = -1;
        private int m_deploymentTimeout = -1;
        private int m_scriptTimeout = -1;
        private ApartmentState m_apartmentState = ApartmentState.Unknown;


        public CommandParameters(string projectCollectionUri, string teamProjectName, string testSettingsName)
        {
            Debug.Assert(!string.IsNullOrEmpty(projectCollectionUri), "Project collection uri cannot be empty");
            Debug.Assert(!string.IsNullOrEmpty(teamProjectName), "Team Project name cannot be empty");
            Debug.Assert(!string.IsNullOrEmpty(testSettingsName), "TestSettings name cannot be empty");

            m_projectCollectionUri = projectCollectionUri;
            m_teamProjectName = teamProjectName;
            m_testSettingsName = testSettingsName;
        }

        public string ProjectCollectionUri
        {
            get { return m_projectCollectionUri; }
        }

        public string ProjectName
        {
            get { return m_teamProjectName; }
        }
        public string TestSettingsName
        {
            get { return m_testSettingsName; }
        }

        public int BucketSize
        {
            get { return m_bucketSize; }
            set { m_bucketSize = value; }
        }

        public bool HasBucketSize
        {
            get { return m_bucketSize != -1; }
        }

        public int DeploymentTimeout
        {
            get { return m_deploymentTimeout; }
            set { m_deploymentTimeout = value; }
        }

        public bool HasDeploymentTimeout
        {
            get { return m_deploymentTimeout != -1; }
        }

        public int ScriptTimeout
        {
            get { return m_scriptTimeout; }
            set { m_scriptTimeout = value; }
        }

        public bool HasScriptTimeout
        {
            get { return m_scriptTimeout != -1; }
        }

        public ApartmentState ApartmentState
        {
            get { return m_apartmentState; }
            set { m_apartmentState = value; }
        }

        public bool HasApartmentState
        {
            get { return m_apartmentState != ApartmentState.Unknown; }
        }

        public bool IsUpdate
        {
            get { return (HasBucketSize || HasDeploymentTimeout || HasScriptTimeout|| HasApartmentState); }
        }


        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();
            builder.Append(string.Format(CultureInfo.CurrentCulture, "Collection={0},", m_projectCollectionUri));
            builder.Append(string.Format(CultureInfo.CurrentCulture, "TeamProject={0},", m_teamProjectName));
            builder.Append(string.Format(CultureInfo.CurrentCulture, "SettingsName={0}", m_testSettingsName));

            if (HasBucketSize)
            {
                builder.Append(",");
                builder.Append(string.Format(CultureInfo.CurrentCulture, "BucketSize={0},", m_bucketSize));
            }

            if (HasDeploymentTimeout)
            {
                builder.Append(",");
                builder.Append(string.Format(CultureInfo.CurrentCulture, "DeploymentTimeout={0},", m_deploymentTimeout));
            }

            if (HasScriptTimeout)
            {
                builder.Append(",");
                builder.Append(string.Format(CultureInfo.CurrentCulture, "ScriptTimeout={0},", m_scriptTimeout));
            }

            if (HasApartmentState)
            {
                builder.Append(",");
                builder.Append(string.Format(CultureInfo.CurrentCulture, "ApartmentState={0},", m_apartmentState));
            }

            return builder.ToString();
        }
 
    }
}

Monday, 18 January 2016

Add to GAC (Global Assembly Cache) with Poweshell Remoting

Script made available here, by me allows the files to be added to GAC (Global Assembly Cache) in a remote machine, using poweshell (This script was created on a great sample script available in this article, which explaines how to copy files using PowerShell remoting). Script can run on Server A and It can copy required assemblies from Server A, to Server B and then add to GAC in Server B. This can be used in a standalone installer script created with poweshell and can be utilized in Release Management.

In order to run the script first you need to enable powershell remoting in Server B (target remote server). To do that run in Server B.

Enable-PSRemotingimage

Max size issue

When running the script you could run in to max file size default limit per file if your assembly is larger than 10MB.

WARNING: Command failed. Sending data to a remote command failed with the following error message: The current deserialized object size of the data received from remote client exceeded allowed maximum object size. The current deserialized object size is 1057
2800. Allowed maximum object size is 10485760. For more information, see the about_Remote_Troubleshooting Help topic.
image

As explained in this stackoverflow Q&A, run below script in remote target server (Server B), to enable larger files.

Register-PSSessionConfiguration -Name AsmNoLimits #or the name you like.image
Set the max file size to 500MB. this is run in Server B (Target remote server).
Set-PSSessionConfiguration -Name AsmNoLimits ` -MaximumReceivedDataSizePerCommandMB 500 -MaximumReceivedObjectSizeMB 500image
In the script this configuration “AsmNoLimits” used, when creating the remote PowerShell session.image

With this change large files (upto 500MB) can be copied .image

image

Adding to GAC

Below script segment allows adding to GAC in the remote computer (Server B).image

Once executed in Server A, file copied from Server A to B and getting added to GAC in Server B.

dir C:\temp\GAC\*.* | .\AddAssembliesToGac-Remote.ps1 -Computername "dolphintfsa.domainx.local" -Credential "domainx\chamindac" -Passthru -Verboseimage

image

You can download the script from technet gallery.

A sample script to call this script would look like below.image

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
<#
need to execute below in remote computer(Admin PS Window) to enable PS Remote

 PS C:\Windows\system32> Enable-PSRemoting

 Then execute the below to allow file size more than 10MB
 
 PS C:\Windows\system32> Register-PSSessionConfiguration -Name AsmNoLimits #or the name you like.
 
 PS C:\Windows\system32> Set-PSSessionConfiguration -Name AsmNoLimits ` -MaximumReceivedDataSizePerCommandMB 500 -MaximumReceivedObjectSizeMB 500

 AsmNoLimits is used in AddAssembliesToGac-Remote.ps1

#>
$username = "yourdomain\yourdomainuser"
$password = ConvertTo-SecureString "yourPassword" -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential `
         -argumentlist $username, $password

dir C:\temp\GAC\*.dll | .\AddAssembliesToGac-Remote.ps1 -Computername "YourRemoteMachine" -Credential $cred -Passthru -Verbose

Monday, 11 January 2016

Part 2 Deploy ASP.Net 4 Web Site - Deploying to Azure Web Site with Visual Studio Team Services Release

We have successfully built and produce downloadble build output in the Part 1 Build ASP.Net 4 Web Site. Let’s look at how we can setup a Release Pipeline with Visual Studio Team Services Release Management, to deploy this web site as an Azure Web Application.
Click green + to create a new release definition.image
Select Azure WebSite deployment and click Ok in the dialog box.image
This will create an environment with Azure Web App Deployment task. Rename the environment added to let’s say DevInt. image
In the Artifacts tab of the release definition, click on Link an artifact source.image
Select the build we have created in Part1.image
image
In Azure Web App Deployment task set the parameters as shown below.image
To link Azure Subscription to your VS Team Services Team Project follow the instructions here. Web App Name is the Azure Web App Name. Use the App Service Location as the Web App Location.image
image
Select Deploy Package from linked artifact. How to publish build artifact is explained in Part1.image
Trigger can be set to Continuous Deployment so that new artifact availability will trigger a deployment. image
Approvers can be assigned but let’s keep it automated. image
image
Let’s trigger a new build using build definition we have created in Part1.image
image
Once the build done release automatically get triggered and get completed. image
image
image
Site is getting deployed to Azure Web App.image

Sunday, 10 January 2016

Link Azure Subscription to Visual Studio Team Services Team Project

Inorder to Team Project in Visual Studio Team Services, to use Azure Deployment in build and deployment tasks,  Azure Susbscriptions should be linked to VS Team Service. To link a subscription you can go to team project manage area by clicking on cog wheel icon and going to services tab.image
image
You can navigate to same by clicking on any Azure related build/release tasks Manage link.image_thumb34
image
Click on New Service Endpoint and select Azure.image_thumb36
Click on link to download subscription publish settings file. Log in to your Azuer subscription and file will be downloaded.image_thumb40
image_thumb43
image_thumb41
Or you can
  • Open a Microsoft Azure PowerShell window
  • Type Get-AzurePublishSettingsFile
  • This will open a browser and automatically download your subscription file.
Open the subscription file named “SubscriptiionName.Date-credentials.publishsettings” and locate the SubscriptionId and ManagementCertificate elements.image_thumb51
This will link your Azure subscription to VS Team Services Team Project.image_thumb53