1. Log in to the Azure portal at https://portal.azure.com➢ navigate to the ADLS container you created in Exercise 3.1➢ create a directory named ReferenceData➢ and then upload frequency.json file to the ReferenceData directory. The frequency.json file is in the Chapter07/Ch07Ex04 directory on GitHub.
  2. Navigate to the Azure Stream Analytics job you created in Exercise 3.17➢ select the Inputs link on the navigation menu ➢ click the + Add Reference Input drop‐down menu ➢ select Blob Storage ➢ enter a name (I used frequency) ➢ select the Select Blob Storage/ADLS Gen2 from the Your Subscription radio button ➢ select the storage account where you placed the reference file in step 1 ➢ select the container ➢ select Connection String from the Authentication Mode drop‐down list ➢ and then enter ReferenceData/frequency.json in the Path Pattern text box. The configuration should resemble Figure 7.16.

FIGURE 7.16 Configure reference data for Azure Stream Analytics use.

  1. Click the Save button ➢ select the Query link on the navigation pane ➢ and then enter the following query into the query window; the query is in the StreamAnalyticsQuery.txt file in the Chapter07/Ch07Ex04 directory on GitHub.
    SELECT frequency.FREQUENCY, brainwaves.VALUE, brainwaves.READING_DATETIME
    INTO ADLS
    FROM brainwaves
    JOIN frequency ON brainwaves.FREQUENCY_ID = frequency.FREQUENCY_ID
  2. Start the Azure Stream Analytics job ➢ download and run the brainjammer.exe file located in the brainjammer‐refData.zip file in the Chapter07/Ch07Ex04 directory on GitHub; the source code is contained in the same directory in the file named Program.cs➢ navigate to the ADLS Output container and path ➢ and then view the output, which should resemble Figure 7.17.

FIGURE 7.17 Use reference data with Azure Stream Analytics.

  1. Stop the Azure Stream Analytics job.

In Exercise 7.4 you uploaded a reference file in JSON format that resembled the following:
{FREQUENCY_ID: 1, FREQUENCY:”THETA”}
{FREQUENCY_ID: 2, FREQUENCY:”ALPHA”}
{FREQUENCY_ID: 3, FREQUENCY:”BETA_L”}
{FREQUENCY_ID: 4, FREQUENCY:”BETA_H”}
{FREQUENCY_ID: 5, FREQUENCY:”GAMMA”}

You then created a reference input alias that provided access to the reference data from the Azure Stream Analytics query. The Azure Stream Analytics job needs to be running in order to access the reference data. Once the job was started, you used the brainjammer.exe application to send a simple JSON document, similar to the following, to your event hub, which flowed into Azure Stream Analytics for analysis and transformation:
{“FREQUENCY_ID”:5,”VALUE”:”0.259″,”READING_DATETIME”:”2022-08-12 08:46:32″}

The query converted the FREQUENCY_ID of 5 to the FREQUENCY name using the reference data. The transformed data was stored into the output sink named ADLS that you configured in Exercise 7.1. The output was stored in JSON format and resembled the following:
{“FREQUENCY”:”GAMMA”,”VALUE”:”0.259″,”READING_DATETIME”:”2022-08-12 08:46:32″}

The data can then be used by any other data analytics product that has access to the container.

Katie Cox

Learn More

Leave a Reply

Your email address will not be published. Required fields are marked *