PowerShell script to open RDP session with an Azure VM

My Teammate Jeremy Foster recently shared some azure goodness that he added into his PowerShell Profile.  Then today, I ran across Brian Farnhill’s “Opening RDP session to an Azure VM with PowerShell” blog post and was inspired to add a simple function to my own PowerShell profile to simplify making RDP connections with my Azure VMs.

From a PowerShell command prompt, I opened my profile in notepad (or the text editor of your choice)

notepad $profile

Then, to the bottom of my profile I added the following function

function rdpvm ($ServiceName,$Name) {
  $vm = (Get-AzureVM -ServiceName $ServiceName -Name $Name)
  if($vm -and $vm.InstanceStatus -eq 'RoleReady') {
    $rdp = (Get-AzureEndpoint -VM $vm | where { $_.LocalPort -eq 3389})
    $fqdn = (New-Object System.URI $vm.DNSName).Authority
    $port = $rdp.Port
    Write-Host "Opening Remote Desktop Session with $($fqdn):$($port)..."
    Start-Process "mstsc" -ArgumentList "/V:$($fqdn):$($port)"
  }
  else {
    Write-Warning "The VM $($vm.Name) is not running ($($vm.InstanceStatus)).  You should start it first"
  }
}

Now, in the future, when I am working with Azure in PowerShell I can simply run the following to open an RDP session with a VM.  Of course, this assumes I’ve already used “Add-AzureAccount” to sign into my azure subscriptions.

rdpvm -ServiceName <MyCloudServiceName> -Name <MyVMName>

Enabling Remote PowerShell Access for Secondary Administrators

If you want to use PowerShell Remoting to run scripts on a remote computer using an account other than the target machine’s built-in administrator account, you will  need to do a couple of things:

  1. On the target machine, create another user account and add it to the built-in “Administrators” group
  2. Set the HKLM/Software/Microsoft/Windows/CurrentVersion/Policies/System/LocalAccountTokenFilterPolicy (DWORD) to a value of 1 (you may need to add the LocalAccountTokeFilterPolicy DWORD value if it doesn’t exist). See http://support.microsoft.com/kb/942817/en-us for more details. 

Once you can do that you can use a Enter-PSSession or Invoke-Command with the credentials you created to remotely run PowerShell scripts against the target machine.

And yes, this applies to remoting into Azure Virtual Machines as well.  Just be aware that for Azure VMs you will need to import the certificate for the remote VM before you can successfully authenticate. 

For more info, check out Michael Washam’s “Introduction to Remote PowerShell with Windows Azure” and Jennelle Crother’s “The Imperfect Lab: Letting Additional Administrators Remotely Connect to Servers” .

Bret’s 70-532 MVA JumpStart Demo Files…

I’m presenting the Developing Microsoft Azure Solutions MVA (http://www.microsoftvirtualacademy.com/liveevents/developing-microsoft-azure-solutions) with Sidney Andrews today (12/19/2014).

We’ll be covering a number of topics:

  1. Azure Web Sites
  2. Cloud Services
  3. Virtual Machines
  4. Azure SQL Database
  5. Storage Services
  6. Application Architecture

Specifically, I’m covering the even numbered modules, on Cloud Services, Azure SQL Database, and Application Architecture.

You can grab a copy of my demos from http://aka.ms/BretsMVA532Demos .  Make sure to restore the NuGet packages in each solution.

Enjoy1

Azure Hackathon Resources

At a Hackathon?  Need quick access to some “Azure How To’s to get you started?” Here are some links.  These resources are just to get your started.  If you need something more in depth, check out “Microsoft Virtual Academy

  1. Windows Azure Pass Usage Tutorial if you don’t have an Azure Pass code, you can always create a free trial
  2. Azure Documentation – Everything you need to know about Microsoft Azure
  3. Quick 3-Minute getting started with Azure videos
  4. Creating a Windows Virtual Machine in Azure – Azure Virtual Machines are a great way to get started with the cloud
  5. Creating a Linux Virtual Machine in Azure – Yep! You can create Linux VMs in Azure.   You can also learn how to install the LAMP stack on your Linux VM 
  6. Create a Node.JS Website in Azure and Deploy from GitHub – Azure websites support the platforms you love like ASP.NET, PHP, Python and Node.js and you can deploy from source control services like Visual Studio Online or GitHub
  7. Visual Studio Online – You can create FREE, PRIVATE projects in Visual Studio Online.  Get more than just source control.
  8. Create an Azure Mobile Service for your Android App – Azure Mobile Services are an extremely powerful way to create backends for your mobile apps!
  9. Create an Azure Mobile Service for your iOS App – And iOS apps
  10. Create an Azure Mobile Service for your HTML5 Client App!
  11. Getting User Data with Azure Mobile Services

“DevTest Scenarios in the DevOps World” Resources

Today, 10/20/2014 Cale Teeter, Charles Sterling, Jeff Levinson and I will be delivering a live session on Microsoft Virtual Academy on “Dev/Test Scenarios in the DevOps World”. 

You can grab a copy of Bret’s Demo Files here: http://1drv.ms/1r0CFJw

New Azure Client OS VM Images for Windows 8.1 and Windows 7

I love the awesome surprises I get in the Azure Management Portal on a regular basis!  Today’s (05/12/2014) was an awesome set of new base images for MSDN subscribers:

image

Yep, you see correctly, Windows 8.1 Enterprise and Windows 7 Enterprise images, including some with Visual Studio 2013 Update 2 already installed! w00t!

I also noticed that a number of new extensions are available as well!  Including “Custom Script” and numerous “Security Extensions” with support for Microsoft Antimalware, as well as Symantec Endpoint Protection and Trend Micro Deep Security Agent.  Time to go learn more! 

SNAGHTML1f5c2b9b

Oh, and look at these tantalizing new preview features! Azure RemoteApp and Windows Azure Files, an SMB File Share service!

SNAGHTML1f659cc8

Global Windows Azure Bootcamp San Diego (GWAB)

Looking forward to seeing everybody at the Global Windows Azure Bootcamp in San Diego tomorrow.  Wanted to get a couple of quick logistical things for the event.  You can also check back here for updates both during and after the event:

Date:

March 29th, 2014 from 9am to 4pm. 

Location:

Microsoft San Diego Office
9255 Towne Centre Drive
Suite 400
San Diego, CA 92121

Parking:

Parking is $12.50 for the day.
If you don’t want to pay for parking you can try to park on the street or over at UTC shopping center.

Please Bring:

Your EventBrite ticket and a laptop (or a Development VM in Azure, see below) with :

As an alternative to having the pre-requisites on your own laptop, you can create a Virtual Machine is Azure that has everything you need.  I have another blog post with a video that walks through that process: How to Use a Windows Azure VM for Windows 8.1 Development

I also have a step by step walkthrough here: Setting up an Azure Virtual Machine For Developers with Visual Studio 2013 Ultimate and SQL Server 2012 Express.

You should be aware that if you are going to create an VM in Azure to use as your “development workstation” the initial setup time can take a couple of hours (It just takes time to install Visual Studio, SQL Server, SDKs, Updates, etc).  Point being, you might want to get that started as soon as possible. 

FAQs:

Q: I signed up for a free trial a while ago but it has expired
A:
You can sign up for another free trial, but you will need to use a different Microsoft Account (aka Live ID).  You can create a new free Microsoft Account by going to signup.live.com . Then once you have a new Microsoft Account sign up for the free trial again.  Note, you may need to use “InPrivate Browsing” in Internet Explorer (Ctrl+Shift+P) or an “Incognito Window” in Chrome (Ctrl+Shift+N)

Q: Can I use Visual Studio Express Versions
A:
Yes, but be aware that many tasks require a full Visual Studio installation.  For general Azure development with Web Sites and Cloud Services you can use the Visual Studio Express for Web editions. 

Q: I don’t have Visual Studio 2013, can I use Visual Studio 2012 (or vice-versa)
A:
Regardless of which version you have, you will likely find labs that are written for a different version.  For the most part, everything works just fine, but you will find some differences between what you see, and what the lab says.  Just use your best judgement, and ask questions if you can’t figure out the differences.

Q: My Azure Portal doesn’t match the screen shots or lab instructions
A: Azure evolves rapidly, but that means that older versions of labs may not match the current state of the service.  For the most part, everything works just fine, but you will find some differences between what you see, and what the lab says.  Just use your best judgement, and ask questions if you can’t figure out the differences.

“Developing Windows Azure and Web Services Jump Start” Demo Files

Hi all, I’ll update this post with more details later, but if you are attending the “Developing Windows Azure and Web Services Jump Start” session with Bruno Terkaly and myself, you can grab a copy of my demo files here:

Grab the demo File from GitHub: http://aka.ms/MvaWsAndAzZip 

Again, I’ll update this post later with the final info after the session!

image

HACKTIVE Hackathon Review & My 3rd Place PhatActive Submission

I spent last weekend (09/21/2013-09/22/2013) at Active.com’s HACKTIVE hackathon. I had an awesome time, met ton’s of great people, and actually placed 3rd in the “developer” category with my “PhatActive” submission. WooHoo!  A big thank you to Active.com, Mashery, Yahoo, Aetna, CoMerge and all the other sponsors for putting on a great event!  As an evangelist, I am involved with a lot of hackathons, etc.  It was so much fun to go as a participant!  And these guys put on an awesome event!

The People and the Place

There was a great turn out for the event.   There were a total of 15 apps presented (three in each of the “categories”, see below).  However, MOST teams had at least two people on them, and some had as many as five.  The room was pretty packed when it came time to present.

The event was held at CoMerge in San Diego.  This is a fantastic facility.  Thank you so much to Robert for the space!

c738e90f39e345bba3449d4e41f02228

Cheston Coantoi, owner of Driveframe LLC, and a seasoned hackathon particiapte was their to help teams focus on the challenge and build compelling presentations.  There were also a number of folks from Active.com as well as Neil Mansilla from Mashery, Jesse Givens from Aetna, Tom Clancy from TAO Venture Capital Partners, and Rik Suhonen from Yahoo.  Lots of support. 

Read the rest of this entry »

10 Easy Steps to Azure Web Site Custom Domains

If you want to add a custom domain name to an Azure Web Site, you are just a few steps away.  This quick tutorial will show you how to configure both your DNS zone, as well as your Azure Web Site. I did make a few assumptions though…

Assumptions:

  1. You have already registered your custom domain with a registrar, and have a DNS provider.  I usually use GoDaddy for this, but there are numerous other choices. Use whichever one you prefer.
  2. Since I usually use GoDaddy as my DNS provider, I will show the steps specific to their tools.  However, you should be able to complete the exact same steps with your own DNS provider’s administration pages
  3. I assume you already have a valid Windows Azure account, and a web site configured.
  4. All of my domain name references assume a “.com” top level domain.  You can use any top level domain name you wish though (“.net”, “.org”, “.us”, etc.)

Ok. let ‘s get started:

Read the rest of this entry »