1
votes

I have the latest version of the Azure Powershell installed (0.9.7). I have a new virtual machine that was created via the Preview Portal. It was created with the new Resource Group model.

I am trying to install a few extensions but I cannot figure out the correct Powershell commands. Most instructions say to use Get-AzureVM. This does not return my VMs. If I use Switch-AzureMode to AzureResourceManager, I can use Get-AzureVM to list my VM (v2 I assume).

It seems none of the Extension scripts are setup for Resource Manager mode. Most of the sample scripts say to use: Get-AzureVM -ServiceName 'CLFeb19WS12R2A' -Name 'CLFeb19WS12R2A' | Set-AzureVMBGInfoExtension -Disable -ReferenceName 'BGInfo' | Update-AzureVM

I have tried all kinds of ways. The AzureVMBGInfoExtension cmdlet is not available in Resource Manager mode.

Any suggestions?

1
This isn't off topic, because it is about "software tools commonly used by programmers." It might be a better fit for serverfault though.Shaun Luttin
What type of VM was it? Windows, Linux, other?Shaun Luttin
It was a Windows VM. I should have probably posted it on Server Fault.Jonathan
Nah. You're on topic. Stackoverflow is fine, in my opinion.Shaun Luttin

1 Answers

2
votes

Create a VM

I created a new VM so that I could help you. I used portal.azure.com > New > Compute > Marketplace > Windows Server > Windows Server 2008 R2 SP1 and chose the Resource Manager deployment model.

Create an Active Directory User

Since we're using the Azure Resource Manager, I needed to create a new Active Directory user so that I could authenticate with Azure PowerShell. That is the only way that I could authenticate.

You can create one using the following steps.

  1. Login to the Azure Portal, and select Active Directory.

  2. If no directory exists, select Create your directory and provide the requested information.

  3. Select your directory and add a new user. This new user is a work or school account.

  4. During the creation of the user, you will be supplied with both an e-mail address for the user and a temporary password. Save this information as it is needed later.

  5. From the Azure portal, select Settings and then select Administrators. Select Add, and add the new user as a co-administrator. This allows the work or school account to manage your Azure subscription.

  6. Finally, log out of the Azure portal and then log back in using the new work or school account. If this is the first time logging in with this account, you will be prompted to change the password.

  7. Make sure you see your subscriptions when you log in as the work or school account.

Oddly enough, Azure Resource Manager seems to work best (or only to work) with if we authenticate with one of those types of accounts.

Install the Most Recent Azure PowerShell Module

Since we need access to the Extension related commandlets, I installed the most recent version of Azure PowerShell. The link shows how to install it via the Web Platform Installer. Once done, you can find out whether you have the correct one by running this:

> (Get-Module azureresourcemanager).Version

Major  Minor  Build  Revision
-----  -----  -----  --------
0      9      7      -1

When we run the following, look at all the Extension related commandlets. Hooray!

> Switch-AzureMode -Name AzureResourceManager
> Get-Command *extension* -Module AzureResourceManager

Get-AzureVMAccessExtension            
Get-AzureVMCustomScriptExtension      
Get-AzureVMDiagnosticsExtension       
Get-AzureVMDscExtension               
Get-AzureVMExtension                  
Get-AzureVMExtensionImage             
Get-AzureVMExtensionImageType         
Remove-AzureVMAccessExtension         
Remove-AzureVMCustomScriptExtension   
Remove-AzureVMDiagnosticsExtension    
Remove-AzureVMDscExtension            
Remove-AzureVMExtension               
Set-AzureVMAccessExtension            
Set-AzureVMCustomScriptExtension      
Set-AzureVMDiagnosticsExtension       
Set-AzureVMDscExtension               
Set-AzureVMExtension

We have access to these while being in Resource Manager mode. To learn how to use each of them, run Get-Help Set-AzureVMAccessExtension -example on each one that is of interest. Then play around with the example.

Authenticate Azure PowerShell & Set the Extensions for Your VM

When authenticating via Add-AzureAccount, use the Active Directory user that we created. Then you can query your virtual machines.

> Add-AzureAccount
> Get-AzureResource -ResourceType Microsoft.Compute/virtualMachines

Once you know the details of your VM, you can add an extensions. Here is one example that worked for me.

>  Set-AzureVMAccessExtension -ResourceGroupName "mvp1" -Location "West US" -VMName "mvp1" -Name "mvp1test" -TypeHandlerVersion "2.0" -UserName "shaunluttin" -Password "Password

EndTime             : 9/1/2015 9:35:57 PM -07:00
Error               :
Output              :
StartTime           : 9/1/2015 9:35:20 PM -07:00
Status              : Succeeded
TrackingOperationId : f03210e0-e67e-40d7-aad7-d9acef64bebe
RequestId           : 95f42767-edcf-443a-8977-4c9f6d0eafef
StatusCode          : OK

Best of luck with that. Let me know if you have any questions.