Code Signing Inflation

A monk illuminates some code

I have been in a Windows software writing funk for the past year because my code signing certificate expired and during those happy three years of signing the industry changed beyond all recognition.

Code signing, or Authenticode, proves that my software came from me and hasn't been altered (as long as I'm not careless with my private key, and some alteration is possible). Windows is increasingly hysterical about running unsigned installers, and for good reason, so I have always signed anything I distribute widely.

For a long time I used K Software, who resold Comodo certificates (now Sectigo), and that cost me $70 a year with a 3 year certificate. K Software doesn't seem to exist any more, and Sectigo's list price is $715 / year. I'm not paying that to distribute free software. Part of the cost increase is that private keys either need to be on secure devices or hosted. Not a bad idea as compromised keys are an obvious disaster. There are some cheaper resellers but any palatable certificate cost seems to require a paid service for the actual signing.

When I last looked at this Microsoft had an interesting option on Azure (Artificat Signing) but it was only open to companies with three years of history, and so I gave up and worked on Android and web apps instead. This has now changed, and you can get an individual code signing service up and running for $10/month. I don't love it, but I'm willing to pay. There is a 'quick start' guide to get you up and running. I highly recommend pasting this into the LLM of your choice for a walkthrough, as it's a miserable process. I have got it going though and released a Catfood Earth update. Because it's a new certificate I'm starting from scratch on anti-virus reputation, unavoidable.

A few tips. Make sure your billing account for Azure is the name you want on the certificate first. Azure is a beast - full of things like progress for activating a service that ends up with it in an unactivated state until you refresh the page, or a mandatory selection on step 2 of a process that blocks you from completing step 1. I don't feel that this is a service they're excited to provide. Identity verification was online and fast which was pleasant (based on a drivers license for me). The person plan requires you to be in the US or Canada and supports up to 5,000 signatures a month.

Using the Azure Monitor REST API from Google Apps Script

By . Updated on

Average Server Response Time in Azure Metrics

This post describes how to get metrics (in this case average response time) from an Azure App Service into a Google Sheet. I’m doing this so I can go from the sheet to a Data Studio dashboard. I already have a report in Data Studio that pulls from Ads, Analytics and other sources. I’d rather spend hours adding Azure there than be forced to have one more tab open. You might have different reasons. Read on. 

  1. Create a Google Sheet and give it a memorable name. Rename the first sheet to AvgResponseTime and put ‘Date’ in A1 and ‘Average Response Time’ in B1.
  2. Create a script (Script editor from the Tools menu) and give that a good name as well.
  3. In the script editor pick Libraries from the Resources menu. Enter 1B7FSrk5Zi6L1rSxxTDgDEUsPzlukDsi4KGuTMorsTQHhGBzBkMun4iDF which is the Google OAuth library, pick the latest version and click Save.
  4. Select Project properties from the File menu and make a note of the Script ID.
  5. Log into your Azure Console and then go to https://resources.azure.com/. You are looking for a metricdefinitions node for the resource that you want to monitor. In my case it’s subscriptions / MyName Subscription / resourceGroups / providers / Microsoft.Web / sites / MySite / metricdefintions. Browse through this list to find the id of the metric you’re interested in. For me it’s AverageResponseTime. Finding this was the hardest part. Microsoft’s documentation for resourceUri is literally ‘The identifier of the resource.’ Why even bother Microsoft? Make a note of the id and remove the ‘metricDefinitions/AverageResponseTime’ from the end, because of course the ID isn’t quite right for some reason. Mine looks something like this: /subscriptions/mylongid/resourceGroups/mysomethingResourceGroup/providers/Microsoft.Web/sites/mysiteid
  6. Go back to the Azure Console and open Azure Active Directory. Select App registrations under Manage and create a New registration. Time to come up with another name. You probably want ‘Accounts in this organizational directory only’. The redirect URL is https://script.google.com/macros/d/SCRIPTID/usercallback - replace SCRIPTID with the Script ID you made a note of in step 4.
  7. Click the View API permissions button, then Add a permission and then pick Azure Service Management. I’m using Delegated permissions and the user_impersonation permission. Then click Grant admin consent for Default Directory.
  8. Go to Certificates & secrets (under manage) and create a new client secret. Make a careful note of it.
  9. Go to Authentication (under Manage), check Access tokens under Implicit grant and then click Save at the top of the page.
  10. Go to Overview and make a note of your Application (client) ID and Directory (tennant) ID.
  11. You are getting close! Go to the script editor (from step 2) and paste in the code at the bottom of this post. There are four variables to enter at the top of the script. ClientID and TennantID are from step 10. ClientSecret is from step 8. ResourceID is from step 5. Save the script.
  12. Reload the spreadsheet (back from step 1). You should get an Azure Monitor menu item. Choose Authorize from this menu. Google will ask you to authorize the script, do this for the Google account you’re using. Choose Authorize again, this time a sidebar will appear with a link. Follow the link and authorize against Azure (if you’re logged in this might just go directly to success). If you get authorization errors in the future run this step again. If that does help use Reset Settings and then try again.
  13. You should be ready to get data. Choose Fetch Data from the Azure Monitor menu. If this doesn’t work check through steps 1-12 carefully again!
  14. Last step - automate. Go back to the script editor. Choose Current project’s triggers from the Edit menu. Add a trigger (the small blue button hidden at the bottom right of the screen - not everything needs a floating action button Google!) to run fetchData daily at some reasonable time.
You should now have a daily record of average response time flowing to a Google sheet. This can easily be extended to support other metrics, and other time periods (you could get data by minute and run the script hourly for instance. See the metrics documentation for more ideas. I got this working for an App Service but it should be roughly the same flow for anything that supports metrics, you’ll just need to work on finding the right resourceUri / ID.