Part-1 : Getting Started With Windows Azure And PowerShell
In my previous post, I have posted about getting started with Windows Azure and PowerShell.
We have already downloaded and installed the Window Azure PowerShell module.
Today we will connect to our Windows Azure subscription with PowerShell, so that we can run Windows Azure PowerShell cmdlets and start automating stuff.
Connect with Windows Azure
There are two ways to connect to the Windows Azure subscription,
1. Windows Azure AD method.
a. We can connect to window Azure using Ad method by providing our Azure subscriptions username and password but the main issue with Windows Azure AD authentication method is, that saved credentials are expired after 12 hours and after expiration we need to login in again. This is not a good choice when we want to automate tasks using PowerShell.
2. Using Certificates
a. When we use certificated method to login, they are valid until the subscription in available and certificates are valid. This is recommended option for automation of the task and for long running scripts.
Connect using Azure AD Method
To connect to Windows Azure using AD method, do the following.
Open Windows Azure PowerShell {or Import-Module Azure in your current PowerShell console.}
Run the Add-AzureAccount cmdlet
This will open a “Sign in to Windows Azure” window.
Provide your windows Azure’s subscription email address and click on continue.
Or might be you will see the below asking for your username and password, provide your details {which you use to login to https://manage.windowsazure.com and click on Sign in.
Once is account is verified, you will be return back to the PowerShell console.
For testing let’s run the Get-AzureAccount cmdlet and see if it return anything.
Get-AzureAccount
Seeming working J and you are successfully connected to the cloud.
Connect using Certificate Method.
To connect to Windows Azure using PowerShell, we need to get our certificate first. To get the certificate please do the following.
1. Open Windows Azure PowerShell console, or import the Windows Azure PowerShell module to your current PowerShell profile.
2. Run the Get-AzurePublishSettingsFile cmdlet
3.
5.
6. This cmdlet redirect to the Windows Azure login page and please provide your Windows Azure login credential to login to the portal.
7. Once you successfully login, you will see the below page and your certificated will download automatically.
9. Now we have to import the publish setting file.
10. Now run Import-AzurePublishSettingsFile cmdlet and provide the path to the certificate which we have just downloaded.
12. Once you run the above cmdlet. Delete your certificate file which we have just downloaded.
For testing let’s run Get-AzureSubscription cmdlet. And everything is working perfectly.
That’s all for now. See you in my next blog post.
Regards
Aman Dhally
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.