Setting up a cloud service to run HDInsight jobs – Part 2

Introduction

Managing an HDInsight cluster, or running an HDInsight job, from an Azure worker role, requires you to set up a certificate to access the HDInsight cluster. This post shows how to upload the certificates to the Azure management portal, and how to configure our cloud service. The previous post (Setting up a cloud service to run HDInsight jobs – Part 1) showed the steps to generate the certificate files we need.

Uploading the certificate files

The .cer file should be uploaded to the Azure portal under the “Management Certificates” section. To do so, follow these steps:

  1. Open the Azure management portal (https://manage.windowsazure.com/).
  2. Go to the settings section (left menu).
    Settings
  3. Go to the “Management Certificates” tab.
    Management Certificates
  4. Click “Upload” on the bottom menu.
    Upload
  5. Browse for your .cer certificate file.
    Browse .cer file
  6. Click OK and the upload will begin. You’ll be notified when it’s ready.

The .pfx file should be uploaded in the “Certificates” section in your Cloud Service. To do so, follow these steps:

  1. Open the Azure management portal (https://manage.windowsazure.com/).
  2. Go to the Cloud Services section on the left menu.
    Cloud Services
  3. Select your Cloud Service from the list.
  4. Go to the Certificates tab.
    Certificates
  5. Click “Upload” on the bottom menu.
    Upload
  6. Browse for the .pfx certificate file and enter the password.
    Browse .pfx
  7. Click OK and wait for the certificate to be available, it will appear in the list when it’s ready.

Set up your certificate in Visual Studio

Now, it’s time for some code!

Open your Cloud Service project in Visual Studio and then open the role’s properties.

In there, go to the Certificates tab.

Role properties

Click “Add Certificate”. This will ask you to set the Name, the location where the certificate will be stored, and the thumbprint for the certificate (you’ll get it when you select the certificate from the list).

Add certificate

That’s almost it! Now, you would be wondering how you access the certificate from your code, here is a helper function to find a certificate from the store:

To get the certificate we configured in the previous step, we’ll need to call the function with these parameters:

  • storeLocation: StoreLocation.LocalMachine
  • storeName: StoreName.My
  • findType: X509FindType.FindByThumbprint
  • searchCriteria: your certificate thumbprint

And that’s it!!!

Summary

In this post we saw how to upload the certificates we created in Part 1 to the Azure portal and how to configure our service to access them.

Happy coding!

@gjbellmann

Advertisements

One thought on “Setting up a cloud service to run HDInsight jobs – Part 2

  1. Pingback: Setting up a cloud service to run HDInsight jobs – Part 1 | Guillermo Bellmann

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s