How to deploy Azure using PowerShell?

I want to deploy my application on azure using powershell. While I created the certificate in the localmachine store, I will not start the deployment of the script as I downloaded the script in azure. The next step is to access the service on the azure screen in PowerShell, but it does not work there. script I still have:

$cert = Get-Item Cert:\LocalMachine\deploy\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Set-AzureSubscription -SubscriptionName $subscriptionName -SubscriptionId $subscriptionId -Certificate $cert Select-AzureSubscription $subscriptionName $service = Get-AzureService $azureId 

The last line displays the following message:

 Get-AzureService : Communication could not be established. This could be due to an invalid subscription ID. Note that subscription IDs are case sensitive. At F:\DeployTest\deploy.ps1:9 char:12 + $service = Get-AzureService $azureId + ~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Get-AzureService], Exception + FullyQualifiedErrorId : Microsoft.WindowsAzure.Management.ServiceManagement.HostedServices.GetAzureServiceCommand Get-AzureService : HTTP Status Code: AuthenticationFailed - HTTP Error Message: The server failed to authenticate the request. Verify that the certificate is valid and is associated with this subscription. Operation ID: At F:\DeployTest\deploy.ps1:9 char:12 + $service = Get-AzureService $azureId + ~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Get-AzureService], CommunicationException + FullyQualifiedErrorId : Microsoft.WindowsAzure.Management.ServiceManagement.HostedServices.GetAzureServiceCommand 

I really don't know what the problem is, the certificate I'm trying to use is loading, so it seems that there is something fundamental that I missed.

Update: I got it to work after loading the .publishsettings file and importing, instead of trying to use Set-AzureSubscription . I'm still a little confused, but shouldn't I use the method I tried above?

+4
source share
1 answer

I finally found the problem, and of course it was a problem with the user. At first, when I was on the azure portal, I did not find where to download the certificate, so I downloaded it to the first place where I found the mention of certificates. What I found out was that this area was wrong, I uploaded the certificate to the certificate area under the cloud service that I wanted to administer, which is the wrong place.

The correct place to download the certificate is under settings in the azure admin portal. Thus, the code above works if the certificate is uploaded to the right place.

+5
source

All Articles