Intranoggin

Blither, Blather, Web Content Management.
Blog » Alexa on Azure: Logging Requests Part 1

Alexa on Azure: Logging Requests Part 1

In the long term, my vision is to have an Azure table hold every type of subject or activity that my skill has been asked about and then to be able to put custom responses into that table that the skill can use. However, my first step is just to simply get the requests dumped into a queue that I can process from another function.

First, we’ll need to create a connection for our storage queue. This will work similar to a database connection string. We’ll have the connection defined as a key value pair in our application settings.

It’s a pretty simple add. We’ll take the path of least resistance here by using both the Azure Portal UI and then integrating back with our local code. Open the Function App in the Azure Portal and browse to the Integrate tab. Then click on the New Output button.

New Output

Choose the Azure Queue Storage and click Select.

Storage Queue

Under the Storage account connection, click the new link.

New Connection

Then select the storage account that corresponds to your current environment. This is dev in my case, but we’ll need to repeat this for each of the other function apps in the other environments.

Choose Storage Account

We’ll shortly be adding a binding to our queue storage account into our function.json file. When we do, we’ll want to be able roll this code through each environment without changing function.json, so it won’t do to use the default connection name that is environment specific.

Env Specific Connection

Click into the Function app settings.

Settings

Inside the Application settings, you’ll find the connection we just created.

Environmental Variable

You can click in that row and rename it something that is not environmentally specific. I chose intranogginalexastorageaccount. don’t forget to click save.

UpdateVariable

You can verify it’s availability by going back to the Integrate tab and selecting it from the drop down for the queue

Verify Connection

You’ll want to go through the above steps for each of your environments to ensure the connection key/value pair is defined for each environment before the code gets promoted there.

Now we’ll update our code to use the new queue. Open function.json, and add a queue binding.

updated function.json

In run.csx, update our function signature to include the queue. Note that the name property above matches the variable name in our function parameter. Write string messages to the queue with:

await alexaAskTeenageRequestQueue.AddAsync(Convert.ToString(data));

Run.csx Updates

Publish your project to Azure and you can then use Microsoft Azure Storage Explorer to verify your queue messages are being written.

Azure Storage Explorer


Posted: 3/16/2017 7:02:00 AM by Ryan Miller | with 0 comments