从Visual Studio Team Services创建Azure DevTest Lab VM

时间:2016-07-25 16:25:59

标签: azure build azure-devops azure-devtest-labs

我想在Visual Studio Team Services中创建Azure DevTest labs VM作为构建过程的一部分。但是,当我运行构建时,我收到以下错误:

******************************************************************************
Starting task: Create Azure DevTest Labs VM
******************************************************************************
Executing the powershell script: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.102.0\tasks\AzureDevTestLabsCreateVM\1.0.7\New-AzureDtlVM.ps1
Looking for Azure PowerShell module at C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Azure.psd1
AzurePSCmdletsVersion= 1.3.2
Get-ServiceEndpoint -Name ***** -Context Microsoft.TeamFoundation.DistributedTask.Agent.Worker.Common.TaskContext
tenantId= ********
azureSubscriptionId= *****
azureSubscriptionName= *****
Add-AzureRMAccount -ServicePrincipal -Tenant ******** -Credential System.Management.Automation.PSCredential
Select-AzureRMSubscription -SubscriptionId ***** -tenantId ********
Starting Azure DevTest Labs Create VM Task
Task called with the following parameters:
  ConnectedServiceName  = *****
  LabId = *****
  TemplateName = C:\a\1\s\MVC app\azure-rm-template
  TemplateParameters = -newVMName 'builder' -userName 'admin' -password (ConvertTo-SecureString -String ***** -AsPlainText -Force)
  OutputResourceId = labVMId
Validating input parameters
Fetching lab *****
Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.ErrorResponses.ErrorResponseMessageException: MissingSubscription : The request did not have a provided subscription. All requests must have an associated subscription Id.
at Microsoft.Azure.Commands.ResourceManager.Cmdlets.RestClients.ResourceManagerRestClientBase.<SendRequestAsync>d__24.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Commands.ResourceManager.Cmdlets.RestClients.ResourceManagerRestClientBase.<SendRequestAsync>d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Commands.ResourceManager.Cmdlets.RestClients.ResourceManagerRestClientBase.<SendRequestAsync>d__1b`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.GetAzureResourceCmdlet.<GetResource>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.GetAzureResourceCmdlet.<GetResources>d__c.MoveNext()

我已使用服务主体将VSTS连接到Azure,并且我正在使用Microsoft提供的DevTest实验室任务(https://marketplace.visualstudio.com/items?itemName=ms-azuredevtestlabs.tasks)。

这是非常令人困惑的,因为错误声称“MissingSubscription”但该任务的日志包含我的所有订阅信息?!?!

1 个答案:

答案 0 :(得分:1)

这可能是由您在“Azure DevTest Labs创建VM”任务中输入的“实验室名称”导致的。确保您已在Azure门户中创建了DevTest实验室,然后在“Azure DevTest Labs创建VM”任务中,您应该从“实验室名称”的下拉列表中看到它,从那里选择它。 enter image description here

如果实验室名称正确,您应该在日志中看到“LabID”与以下格式相同:

LabId = /subscriptions/subscriptionID/resourceGroups/resourcegroupname/providers/Microsoft.DevTestLab/labs/LabName