Teamcity installed on VM created in Azure

Hi

I had created a VM in Azure and instaled Teamcity on this VM. Now i want to deploy my apps thro Teamcity and powershell scripts.
When I run my scripts directly on powershell on VM then they execute with no issues and my app gets deloyed, but the same if i try with the build steps (powershell) then it says

Set-AzureService : ForbiddenError: The server failed to authenticate the

request. Verify that the certificate is valid and is associated with this

subscription.


Is this some kind of certificate issue ? if so what has to be done ?

Does Teamcity requires some kinda certificate to execute the scripts and powershell cmdlets ?

Teamcity and the VM user which i use to access it, both have same set of permission.

What do i need to check and get this up working?

Can any body pls guide me thro' ?

1 comment
Comment actions Permalink

I finally got the sloution

The error message that I got is

Set-AzureService : ForbiddenError: The server failed to authenticate the
request. Verify that the certificate is valid and is associated with this subscription.

It’s a bit misleading because as you can see in the code below (esp: last line), I did set the current storage but why did I get this message?

[05:14:33][Step 3/3] Set-AzureService : ForbiddenError: The server failed to authenticate the
[05:14:33][Step 3/3] request. Verify that the certificate is valid and is associated with this
[05:14:33][Step 3/3] subscription.
[05:14:33][Step 3/3] At line:1 char:1
[05:14:33][Step 3/3] + Set-AzureService -ServiceName $service -Label $deploymentLabel
[05:14:33][Step 3/3] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[05:14:33][Step 3/3] + CategoryInfo          : CloseError: (:) [Set-AzureService], ComputeCloud
[05:14:33][Step 3/3] Exception
[05:14:33][Step 3/3] + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagemen
[05:14:33][Step 3/3] t.HostedServices.SetAzureServiceCommand

The script was working fine when run in VM Powershell but failed when run with Teamcity.
To resolve this I followed the following Steps :

  • Open Windows Powershell on VM
  • Run "Get-AzurePublishSettingsFile". It will ask you to login to Azure and you will get the publish setting file for your Azure Subscription associated with your account.
  • Then run "Add-AzureAccount", It will ask you to login and your account will be added to powershell.
  • Login to Azure Portal (manage.windowsazure.com).
  • Go to Settings => Management Certificates section. Get the ThumbPrint of the recently added PublishSettingCertificate.
  • On Powershell run Import-AzurePublishSettingsFile "path of your publish setting file on VM"
  • run Add-AzureCertificate -serviceName "Your service Name" -certToDeploy (get-item cert:\CurrentUser\MY"Certificate ThumbPrint you got from Azure")
  • Finally "Get-AzureSubscription", to see the subscriptions added on Powershell.


Hope this helps some one :)

0

Please sign in to leave a comment.