Set-AzureSubscription : The subscription doesn't exist.

I am deploying the app on cloud service created on subscription
"Windows Azure for BizSpark Plus"

I have two subscriptions for my Azure Account. Some of the Services are in "wwindia" subscription and some are in "Windows  Azure for BizSpark Plus" subscription. The Powershell script runs for deploying apps in "wwindia" but not in "Windows  Azure for BizSpark Plus".

[10:52:15][Step 3/3] Set-AzureSubscription : The subscription name Windows Azure for BizSpark Plus

[10:52:15][Step 3/3] doesn't exist.

[10:52:15][Step 3/3] Parameter name: name

[10:52:15][Step 3/3] At line:1 char:1

[10:52:15][Step 3/3] + Set-AzureSubscription -CurrentStorageAccount $storageAccount

[10:52:15][Step 3/3] -SubscriptionName $ ...

[10:52:15][Step 3/3] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[10:52:15][Step 3/3] ~~~

[10:52:15][Step 3/3] + CategoryInfo : CloseError: (:) [Set-AzureSubscription], Argumen

[10:52:15][Step 3/3] tException

[10:52:15][Step 3/3] + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.SetAzure

[10:52:15][Step 3/3] SubscriptionCommand

[10:52:15][Step 3/3]

[10:52:31][Step 3/3] Set-AzureService : ResourceNotFound: The hosted service does not exist.

[10:52:31][Step 3/3] OperationID : '3f4a7e7e0dc5c7878fdccd9c0048e318'

[10:52:31][Step 3/3] At line:1 char:1

[10:52:31][Step 3/3] + Set-AzureService -ServiceName $service -Label $deploymentLabel

[10:52:31][Step 3/3] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[10:52:31][Step 3/3] + CategoryInfo : CloseError: (:) [Set-AzureService], ComputeCloud

[10:52:31][Step 3/3] Exception

[10:52:31][Step 3/3] + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagemen

[10:52:31][Step 3/3] t.HostedServices.SetAzureServiceCommand

[10:52:31][Step 3/3]

[10:52:32][Step 3/3] Create Azure Deployment

[10:52:33][Step 3/3] 8/6/2015 10:52 AM - No deployment is detected. Creating a new deployment.

[10:52:33][Step 3/3] 8/6/2015 10:52 AM - Creating New Deployment: In progress

[10:53:07][Step 3/3] New-AzureDeployment : ResourceNotFound: The hosted service does not exist.

[10:53:07][Step 3/3] OperationID : '939cf2debd4bcaf1b2800da00c5943be'

[10:53:07][Step 3/3] At line:5 char:15

[10:53:07][Step 3/3] + $opstat = New-AzureDeployment -Slot $slot -Package $package

[10:53:07][Step 3/3] -Configuration $ ...

[10:53:07][Step 3/3] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[10:53:07][Step 3/3] ~~~

[10:53:07][Step 3/3] + CategoryInfo : CloseError: (:) [New-AzureDeployment], ComputeCl

[10:53:07][Step 3/3] oudException

[10:53:07][Step 3/3] + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagemen

[10:53:07][Step 3/3] t.HostedServices.NewAzureDeploymentCommand

[10:53:07][Step 3/3]

[10:53:09][Step 3/3] Get-AzureDeployment : ResourceNotFound: No deployments were found.

[10:53:09][Step 3/3] OperationID : '65078d013c03c55eaa099eaefff089e0'

[10:53:09][Step 3/3] At line:6 char:27

[10:53:09][Step 3/3] + $completeDeployment = Get-AzureDeployment -ServiceName $service -Slot

[10:53:09][Step 3/3] $slot

[10:53:09][Step 3/3] +

[10:53:09][Step 3/3] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[10:53:09][Step 3/3] + CategoryInfo : CloseError: (:) [Get-AzureDeployment], ComputeCl

[10:53:09][Step 3/3] oudException

[10:53:09][Step 3/3] + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagemen

[10:53:09][Step 3/3] t.HostedServices.GetAzureDeploymentCommand

[10:53:09][Step 3/3]

[10:53:09][Step 3/3] 8/6/2015 10:53 AM - Creating New Deployment: Complete, Deployment ID:

[10:53:09][Step 3/3] Process exited with code 0

I had the service created on the said subscription, the publich setting file is also for the same subscription.


Upon this I ran these scripts to Posershell,
remove-AzureAccount
add-AzureAccount
select-AzureSubscription -SubscriptionName <name>
before running my script


Things started working smoothy.

I was able to deploy on, but doing the same thing (deploying) the other app started giving me the same problem. Even the earlier one is not working now

I am able to deploy apps in "wwindia" Subscription
but not with "Windows Azure for BizSpark Plus" Subscription

thinking might becertificate issue I added certificates and uploded to Azure
with the help of following link :


Article on how to connect poweshell to azure by uploading a certificate.
http://blogs.msdn.com/b/cindygross/archive/2014/04/19/getting-started-with-azure-powershell-cmdlets-subscription-management.aspx





I gone thro' the link and added certificates for each Azure subscription,
Now I am able to run the powershell script manually on each account
But the next problem I am facing is when I deploy my app manually going to powershell and run the scrip there it deploys and wins.
But when I run the same script on same VM thro' TeamCity powershell it says
   

[12:06:47][Step 3/3] Get-Item : Cannot find path

[12:06:47][Step 3/3] 'Cert:\CurrentUser\My\<MyThumbnail>' because it

[12:06:47][Step 3/3] does not exist.

[12:06:47][Step 3/3] At line:1 char:12

[12:06:47][Step 3/3] + $status = (Get-Item cert:\\CurrentUser\My\$thumbprint).HasPrivateKey

[12:06:47][Step 3/3] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[12:06:47][Step 3/3] + CategoryInfo : ObjectNotFound: (Cert:\CurrentUs...7E5B1B37AFE6B

[12:06:47][Step 3/3] E5:String) [Get-Item], ItemNotFoundException

[12:06:47][Step 3/3] + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetIt

[12:06:47][Step 3/3] emCommand

[12:06:47][Step 3/3]

[12:06:47][Step 3/3] Ceritificate Exist :

[12:06:47][Step 3/3] Get-ChildItem : Cannot find path

[12:06:47][Step 3/3] '\CurrentUser\My\<MyThumbnail>' because it does  not

[12:06:47][Step 3/3] exist.

[12:06:47][Step 3/3] At line:1 char:15

[12:06:47][Step 3/3] + $myCert1 = ( Get-ChildItem -Path cert:\CurrentUser\My\$thumbprint )

[12:06:47][Step 3/3] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[12:06:47][Step 3/3] + CategoryInfo : ObjectNotFound: (\CurrentUser\My...7E5B1B37AFE6B

[12:06:47][Step 3/3] E5:String) [Get-ChildItem], ItemNotFoundException

[12:06:47][Step 3/3] + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetCh

[12:06:47][Step 3/3] ildItemCommand

[12:06:47][Step 3/3]

[12:06:48][Step 3/3] Set-AzureSubscription : The term 'Set-AzureSubscription' is not recognized as

[12:06:48][Step 3/3] the name of a cmdlet, function, script file, or operable program. Check the

[12:06:48][Step 3/3] spelling of the name, or if a path was included, verify that the path is

[12:06:48][Step 3/3] correct and try again.

[12:06:48][Step 3/3] At line:1 char:1

[12:06:48][Step 3/3] + Set-AzureSubscription ?SubscriptionName $localSubName ?SubscriptionId

[12:06:48][Step 3/3] $subID - ...

[12:06:48][Step 3/3] + ~~~~~~~~~~~~~~~~~~~~~

[12:06:48][Step 3/3] + CategoryInfo : ObjectNotFound: (Set-AzureSubscription:String) [

[12:06:48][Step 3/3] ], CommandNotFoundException

[12:06:48][Step 3/3] + FullyQualifiedErrorId : CommandNotFoundException

[12:06:48][Step 3/3]

[12:06:48][Step 3/3] Set-AzureSubscription : The term 'Set-AzureSubscription' is not recognized as

[12:06:48][Step 3/3] the name of a cmdlet, function, script file, or operable program. Check the

[12:06:48][Step 3/3] spelling of the name, or if a path was included, verify that the path is

[12:06:48][Step 3/3] correct and try again.

[12:06:48][Step 3/3] At line:1 char:1

[12:06:48][Step 3/3] + Set-AzureSubscription -SubscriptionName $localSubName

[12:06:48][Step 3/3] -CurrentStorageAccount $ ...

[12:06:48][Step 3/3] + ~~~~~~~~~~~~~~~~~~~~~

[12:06:48][Step 3/3] + CategoryInfo : ObjectNotFound: (Set-AzureSubscription:String) [

[12:06:48][Step 3/3] ], CommandNotFoundException

[12:06:48][Step 3/3] + FullyQualifiedErrorId : CommandNotFoundException

[12:06:48][Step 3/3]

[12:06:48][Step 3/3] Select-AzureSubscription : The term 'Select-AzureSubscription' is not

[12:06:48][Step 3/3] recognized as the name of a cmdlet, function, script file, or operable

[12:06:48][Step 3/3] program. Check the spelling of the name, or if a path was included, verify

[12:06:48][Step 3/3] that the path is correct and try again.

[12:06:48][Step 3/3] At line:1 char:1

[12:06:48][Step 3/3] + Select-AzureSubscription ?Current $localSubName

[12:06:48][Step 3/3] + ~~~~~~~~~~~~~~~~~~~~~~~~

[12:06:48][Step 3/3] + CategoryInfo : ObjectNotFound: (Select-AzureSubscription:String

[12:06:48][Step 3/3] ) [], CommandNotFoundException

[12:06:48][Step 3/3] + FullyQualifiedErrorId : CommandNotFoundException

[12:06:48][Step 3/3]

[12:06:48][Step 3/3] Get-AzureSubscription : The term 'Get-AzureSubscription' is not recognized as

[12:06:48][Step 3/3] the name of a cmdlet, function, script file, or operable program. Check the

[12:06:48][Step 3/3] spelling of the name, or if a path was included, verify that the path is

[12:06:48][Step 3/3] correct and try again.

[12:06:48][Step 3/3] At line:1 char:2

[12:06:48][Step 3/3] + (Get-AzureSubscription -Current).SubscriptionName

[12:06:48][Step 3/3] + ~~~~~~~~~~~~~~~~~~~~~

[12:06:48][Step 3/3] + CategoryInfo : ObjectNotFound: (Get-AzureSubscription:String) [

[12:06:48][Step 3/3] ], CommandNotFoundException

[12:06:48][Step 3/3] + FullyQualifiedErrorId : CommandNotFoundException
This is weird. I had created a VM on Azure and automating deploying the apps thro' teamcity.
When I try
(Get-ChildItem -Path cert:\CurrentUser\My\135316F9CBC79ADFD48E62F007E5B1B37AFE6BE5 )
on powershell on this VM it returns the thnmbprint and CN.
but the same line does not work when run in Teamcity powershell.
On this Same VM it deployes the app to azure whn ran manually but not with TeamCity.

Can any one pls help me to get this working ?

4 comments
Comment actions Permalink

Here the deployment do not work When run on Teamcity
and works on Powershell when run directly



Attachment(s):
Directly on Powershell.png
TeamnCityRun.png
0
Comment actions Permalink

Please make sure that user who runs teamcity build agent has all nesessary permissions.

0
Comment actions Permalink

I had logged in with Administator and the the permission set are same for both the user.
Does Teamcity uses some cetificate to comunicate with Azure Cloud ?
Because this issue came when i deleted Certificates on Azure.

0
Comment actions Permalink

I finally got the cause (wierd)


On VM PowerShell when i  ran get-AzureSubscription it returned me "Windows Azure for BizSpark Plus"

And when I ran the same by Teamcity if got me "Windows Azure BizSpark 1111"

So I changed the subscription name in my scripts and error went off.

0

Please sign in to leave a comment.