Really, I am not going to go into a lot of explanation here. I am assuming that you have some PowerShell background and need a bit to get started. That is what I am covering.
You can find the cmdlets here:
https://www.windowsazure.com/en-us/manage/downloads/
Be sure to have your Azure management certificate properly stored in your Personal certificate store prior to connecting to your subscription.
These first commands are pretty much mandatory when you begin a PowerShell session.
Import the module:
import-module 'C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\Azure.psd1'
Import a settings file (this speeds up as it lists all subscriptions you have access to - to create this file perform Export-AzurePublishSettingsFile (Visual Studio also uses this))
Import-AzurePublishSettingsFile 'C:\Users\Public\Documents\BrianEhServices.publishsettings'
Choose the subscription that you will interact with for your session:
Select-AzureSubscription -SubscriptionName "Sample Subscription"
Set the default Storage account that will be used (it must be in the same subscription)
Set-AzureSubscription -SubscriptionName "Sample Subscription" –CurrentStorageAccount SampleStorageAccount
By the way, do the above is handy. Like me I assume that you all have alt least two Azure subscriptions (yours and the one your company has given you access to). Using that settings file allows easy switching. Now that you have that, go exploring.
If you have a Service or have deployed a Virtual Machine from the Gallery using the Portal you can query it, change it, dispose of it.
If you have VHD images you can manipulate those. Now, disclaimer here, my experience so far is that CSUPLOAD from the Azure SDK is still the best way to get VHDs into Azure storage and it now supports both stateless and persistent VHD images. It differentiates between the two because it registers them with the VHD repository for you and sets its life in motion.
But, I assume that you are getting itchy, so lets just begin with making a new Virtual Machine in a new Service. The very same thing that you would get if you used a Gallery VM image (this is not the Quick VM as that would be New-AzureQuickVM).
First we need to find an image:
List all available images: Get-AzureVMImage
List all available in a table: Get-AzureVMImage | Format-Table
Find images that have been uploaded to your Storage account ('user' images): Get-AzureVMImage | where { ($_.Category -eq "user") }
Now I just want to use the Server 2012 Gallery image and create a VM (we will build on this command).
$svr2012Image = Get-AzureVMImage | where { ($_.Category -eq "Microsoft") -and ($_.Label -match "Server 2012" ) -and ($_.ImageName -match "Datacenter") }
Apply a customization configuration to the image:
$myImage = New-AzureVMConfig -Name MyNewMachine -InstanceSize ExtraSmall -ImageName $svr2012Image.ImageName
Add-AzureProvisioningConfig -VM $myImage -Windows –Password <complex password>
Create the Service and Provision the VM:
New-AzureVM -ServiceName "MyNewService" –VMs $myImage
Notice after it is finished that Azure automatically created an RDP endpoint to allow remote OS access (if it was a Linux image an SSH endpoint would have been created).
No comments:
Post a Comment