Azure APIM JSON Conversion

This week I was working on an Azure Function Web Hook to receive data from a third party service.

The service I was receiving the data from was a little limited in that all I could provide was an endpoint where the data would be posted, and an example of how the data would be formatted.

{
“cc”: [],
“completed_at”: null,
“cost”: null,
“direction”: “inbound”,
“encoding”: “GSM-7”,
“errors”: [],
“from”: {
“carrier”: “”,
“line_type”: “”,
“phone_number”: “+44123456789”
},
“id”: “22737cb8-39d3-42a9-aded-12c0c0c93f80”,
“media”: [],
“messaging_profile_id”: “xxxx-xxxx-xxxxx-xxxxx”,
“organization_id”: “xxxx-xxxxx-xxxxx-xxxx”,
“parts”: 1,
“received_at”: “2023-02-07T12:57:44.753+00:00”,
“record_type”: “message”,
“sent_at”: null,
“subject”: “”,
“tags”: [],
“text”: “Test 2”,
“to”: [
{
“carrier”: “phone service”,
“line_type”: “Wireless”,
“phone_number”: “+441234567890”,
“status”: “webhook_delivered”
}
],
“type”: “SMS”,
“valid_until”: null,
“webhook_failover_url”: null,
“webhook_url”: “my webhook url”
}

In testing my function in PowerShell on my laptop, everything worked as expected, the simulated JSON data I provided was parsed and the result was as expected.

Once I published the function and linked it to the Azure APIM service, I did another test from PowerShell and as everything worked, I confirmed the URL with the third party api and sent a test message.

Unfortunately, it didn’t work. The request was received, the function executed but nothing happened.

A very long story short, I added some output to the function to see the content of the data the third part was sending, and also, crucially, the headers they were sending.

As it turned out, the content type header was not specified as “application/json“, but rather “application/www-urlencoded“. What this means, is that when Azure receives the data it is not automatically parsed, and you need to rely on your own parser to get the JSON data formatted correctly.

The solution was so simple I couldn’t believe it took me so long to find it.

In Azure APIM there is a section under either your post or get requests, where you can supply a policy. One of the aspects of the policy is overriding headers.

So, by added my own Content Type header, for application/json and setting it to override, the data arriving at my function was parsed for me, and I could then access the data for further processing.

Hopefully will save someone some time!

Quick Fix: Office 2019 Volume License ODT Error

Spent too long troubleshooting this, because I, like most men, do not read the manual.

Trying to deploy Office 2019 Standard Volume License using the ODT. Using a config file I created at config.office.com. After running the setup.exe /configure configure.xml command you receive an error saying unable to download a required file or similar.

Solution – remove en-GB from your list of languages.

en-GB is only supported in builds newer than 2108 and Office 2019 is currently on build 1808.

It says it here, I just didn’t think to check because I was using the Config tool to build the file.

Lesson learned.

Quick Fix: SBS 2011 wbadmin parameter incorrect

I never thought i’d be writing about SBS 2011 again, but here she is, back from the dead.

I’m working on a migration SBS 2011 > 2019 and as per my guide i was trying to get a system state backup of the source server before making any changes. Well, the SBS had other ideas.

Running the command

wbadmin start systemstate backup -backuptarget:g:

Would result in an error ‘parameter incorrect’ after a few minutes.

Read more of this post

Google Chrome Double Typing Characters

Do you own a large oaf like feline? Has it just sauntered on to your laptop and decided to sleep on the keyboard, despite you being midway through typing something? Then you may be suffering from a case of AnoyingOaflikeCat-itis.

help

Read more of this post

Introducing Windows Server 2019 Essentials

With the release of Server 2019 Essentials, the end of an era has been reached. Gone are the wizards and tools designed for the small business owner.

Gone is the Remote Web Access feature.

Gone is the Essentials Connector.

Gone is Client PC Backup.

Gone is Office 365 Integration.

Gone, is the Dashboard.

Gone, indeed, is the Essentials Role.

All that remains of Essentials, is the name Essentials and the licensing limits of the Essentials SKU, of 25 client access licenses.

What we are presented with, is now more in line with Windows foundation server from several years ago.

Office 365 Password Policy returns Empty Values in PowerShell

o365-logo1Regular readers will be aware of a script I wrote some time ago to remind people to change their password, sending them an email when it was due to be changed. I wanted to extend this up to Office 365 but at the time, when I checked it out the relevant data was not exposed by using the Get-MSOLPasswordPolicy cmdlet. Or so I thought.

Whilst chatting with co-conspirator Tim Barrett yesterday he sent me a link to Spice Works where someone named bbeckers had indeed published a modified version of my original script that was talking to Office 365, and, to my surprise was dated back in 2016.

Of course I wanted to try it out, but on my production tenant, the information returned from Get-MSOLPasswordPolicy was an error saying ‘You do not have permission to call this cmdlet’

Read more of this post

Quick Fix : Clean-up Duplicate Remote Web Access Certificates

SSLI noticed this thread in the forum a while ago, and setup a Lab network to reproduce it. Sure enough after a few days, my local machine certificate store is full of duplicated certificates.

The issue only seems to affect Essentials 2016 and only if you are using the free remotewebaccess.com certificates.

The issue is also discussed here on the MCB Systems blog.

Unfortunately for me work took over and i was not able to spend any more time on it, and with responses from Microsoft for any Essentials related issue being, shall we say, pedestrian, i wont be holding out any hope of a fix soon.

Read more of this post

%d bloggers like this: