Monitoring Azure applications – Part 2
The “Monitoring Azure applications” series:
- Part 1: Enabling instrumentation and monitoring in your Azure app(s)
- Part 2: Setting up the handshake
- Part 3: Discovering your application
- Part 4: When things don’t work
In this blog post I’m going to cover how to get the certificate pieces setup, which allow mutual authentication between Azure applications and your OpsMgr infrastructure. Since I primarily came from an OpsMgr background, I had very little experience with certificates and I definitely didn’t know what was involved in the Azure side.
The first thing that needs to be sorted out is authentication between your Azure application(s) and your OpsMgr manager infrastructure. Given that we’re talking about potentially sensitive data, which is being routed over the internet, it’s very important that this whole channel be as secure as possible. Since we can’t rely on a domain level-trust we have to use an approach not entirely unlike certificate based mutual authentication for agents, but since we’re working Azure, we’re going to be authenticating with the Windows Azure Service Management API instead of with one or more HealthServices. No need to worry though, all communication with the Service Management API is mutually authenticated over SSL.
Create a certificate to be used
As I mentioned, I’m not really a pro in this area, so I won’t run the risk of misinforming folks on how to get your hands on a certificate. Within Microsoft, we have a formalized process for requesting certificates from our central certificate authority, so that is what we did. Later, I found that Walter Myers gives some great instructions in his primer (starting about 1/3 of the way down) on how to create a certificate yourself with IIS, and that cleared up a lot of things for me. Following are the key (sorry, but I couldn’t resist) best practices we learned:
- We extended the expiration date of the cert for as long as we could: You will have to renew your certs, but the further apart that can be, the less effort on your part. The trade-off here is risk, but you can always programmatically push out a new cert and remove the old one if you need to.
- We keep the private key (.PFX), and its password, secret and safe: Anyone who gets this certificate can do anything with the Azure applications it gets added to. Those who are familiar with certificates or the service management API
are thinking this is obvious, but for me as an OpsMgr administrator, this is a good reminder as I don’t work with certificates much at all and up until I’d never worked with the service management API.
Add the public key (.CER) to your Azure subscriptions as a “Management Certificate”
Once we have the certificate we now need to configure the Azure subscriptions, so that they will accept communications signed with this certificate. We do this by uploading the public key portion of the certificate up to our subscription, as a managed certificate. Following are the steps involved:
- Export the public key (.CER file) from the private key (.CER file). Again, this is covered well in Walter Myers’ primer Open the Azure management portal Click on Hosted Services, Storage Accounts & CDN
- In the left-hand folder list click on Management Certificates
- For each subscription you want to monitor, click the Add Certificate and import the certificate for each
Create the Run As Accounts required for certificate based authentication
Lastly, we need to create two RunAs accounts within Operations Manager, which contain the full certificate (binary authentication) and the password to access the full certificate (basic authentication) respectively. This too, is a relatively new concept, even for folks with an OpsMgr background, but fortunately you only have to set it up once.
Open the Operations Manager Console
Switch to the Administration section
Navigate to Run As Configuration -> Accounts
Right-Click on the right-hand pane, where the accounts are shown, and select Create Run As Account… to create the binary authentication run as account, which will hold the certificate file:
- On the General Properties section select Binary Authentication from the drop-down list for Run As account type and in the display name, we provided something like “Azure Monitoring – Certificate”
- On the Credentials section, click browse and navigate to the .PFX file for the certificate
- On the Distribution Security section we opted to go with More Secure and then added the Azure watcher node, to the list of systems that were approved to have the account distributed to it.
- We then created the account.
Back at the Run As Account screen, we need to create a 2nd run as account. Right-Click on the right-hand pane, where the accounts are shown, and select Create Run As Account… to create the basic authentication run as account, which will hold the password that is used to access the private key within the certificate:
- On the General Properties section select Basic Authentication from the drop-down list for Run As account type and in the display name, we provided something like “Azure Monitoring – Certificate Password”
- On the Credentials section, we gave the account name of “Azure Monitoring – Certificate Password”, and the password we put here is the password of the PFX file.
- Again, on the Distribution Security section we opted to go with More Secure and then added the Azure watcher node, to the list of systems that were approved to have the account distributed to it.
- We then created the account.
Note: The Run As Accounts and Run As Profiles topic gives an overview of the various types of accounts available, and how they relate to profiles. The Security Considerations section of the Azure MP guide, gives the specific details relevant to this MP.
So that’s it! Now we have the pieces in place between our Azure subscriptions and our monitoring infrastructure, to allow discovery and monitoring via the service management API.