Hosting a permanent redirect in Azure

WordPress charges for each domain attached to a blog. That is a bit much when you consider .net, .org, .whatever domains that are used on top of the .com domain most use. To get the use out of a single domain, a permanent redirect can be used.  Since Azure has a fixed price, invariant of how many domains you host there; it can be used for the permanent redirect.

Prerequisites

To complete this tutorial:

  • Create an App Service app, or use an app that you created for another tutorial.
  • Purchase a domain name and make sure you have access to the DNS registry for your domain provider (such as GoDaddy).

    For example, to add DNS entries for contoso.com and www.contoso.com, you must be able to configure the DNS settings for the contoso.comroot domain.

    Note

    If you don’t have an existing domain name, consider purchasing a domain using the Azure portal.

Prepare the app

To map a custom DNS name to a web app, the web app’s App Service plan must be a paid tier (SharedBasicStandard, or Premium). In this step, you make sure that the App Service app is in the supported pricing tier.

Note

App Service Free and Shared (preview) hosting plans are base tiers that run on the same Azure VM as other App Service apps. Some apps may belong to other customers. These tiers are intended to be used only for development and testing purposes.

Sign in to Azure

Open the Azure portal and sign in with your Azure account.

From the left menu, select App Services, and then select the name of the app.

Portal navigation to Azure app

You see the management page of the App Service app.

Check the pricing tier

In the left navigation of the app page, scroll to the Settings section and select Scale up (App Service plan).

Scale-up menu

The app’s current tier is highlighted by a blue border. Check to make sure that the app is not in the F1 tier. Custom DNS is not supported in the F1tier.

Check pricing tier

If the App Service plan is not in the F1 tier, close the Scale up page and skip to Map a CNAME record.

Scale up the App Service plan

Select any of the non-free tiers (D1B1B2B3, or any tier in the Production category). For additional options, click See additional options.

Click Apply.

Check pricing tier

When you see the following notification, the scale operation is complete.

Scale operation confirmation

Map your domain

You can use either a CNAME record or an A record to map a custom DNS name to App Service. Follow the respective steps:

Note

You should use CNAME records for all custom DNS names except root domains (for example, contoso.com). For root domains, use A records.

Map a CNAME record

In the tutorial example, you add a CNAME record for the www subdomain (for example, www.contoso.com).

Access DNS records with domain provider

Note

You can use Azure DNS to configure a custom DNS name for your Azure Web Apps. For more information, see Use Azure DNS to provide custom domain settings for an Azure service.

Sign in to the website of your domain provider.

Find the page for managing DNS records. Every domain provider has its own DNS records interface, so consult the provider’s documentation. Look for areas of the site labeled Domain NameDNS, or Name Server Management.

Often, you can find the DNS records page by viewing your account information, and then looking for a link such as My domains. Go to that page and then look for a link that is named something like Zone fileDNS Records, or Advanced configuration.

The following screenshot is an example of a DNS records page:

Example DNS records page

In the example screenshot, you select Add to create a record. Some providers have different links to add different record types. Again, consult the provider’s documentation.

Note

For certain providers, such as GoDaddy, changes to DNS records don’t become effective until you select a separate Save Changes link.

Create the CNAME record

Add a CNAME record to map a subdomain to the app’s default hostname (<app_name>.azurewebsites.net, where <app_name> is the name of your app).

For the www.contoso.com domain example, add a CNAME record that maps the name www to <app_name>.azurewebsites.net.

After you add the CNAME, the DNS records page looks like the following example:

Portal navigation to Azure app

Enable the CNAME record mapping in Azure

In the left navigation of the app page in the Azure portal, select Custom domains.

Custom domain menu

In the Custom domains page of the app, add the fully qualified custom DNS name (www.contoso.com) to the list.

Select the + icon next to Add hostname.

Add host name

Type the fully qualified domain name that you added a CNAME record for, such as www.contoso.com.

Select Validate.

The Add hostname page is shown.

Make sure that Hostname record type is set to CNAME (www.example.com or any subdomain).

Select Add hostname.

Add DNS name to the app

It might take some time for the new hostname to be reflected in the app’s Custom domains page. Try refreshing the browser to update the data.

CNAME record added

If you missed a step or made a typo somewhere earlier, you see a verification error at the bottom of the page.

Verification error

Map an A record

In the tutorial example, you add an A record for the root domain (for example, contoso.com).

Copy the app’s IP address

To map an A record, you need the app’s external IP address. You can find this IP address in the app’s Custom domains page in the Azure portal.

In the left navigation of the app page in the Azure portal, select Custom domains.

Custom domain menu

In the Custom domains page, copy the app’s IP address.

Portal navigation to Azure app

Access DNS records with domain provider

Note

You can use Azure DNS to configure a custom DNS name for your Azure Web Apps. For more information, see Use Azure DNS to provide custom domain settings for an Azure service.

Sign in to the website of your domain provider.

Find the page for managing DNS records. Every domain provider has its own DNS records interface, so consult the provider’s documentation. Look for areas of the site labeled Domain NameDNS, or Name Server Management.

Often, you can find the DNS records page by viewing your account information, and then looking for a link such as My domains. Go to that page and then look for a link that is named something like Zone fileDNS Records, or Advanced configuration.

The following screenshot is an example of a DNS records page:

Example DNS records page

In the example screenshot, you select Add to create a record. Some providers have different links to add different record types. Again, consult the provider’s documentation.

Note

For certain providers, such as GoDaddy, changes to DNS records don’t become effective until you select a separate Save Changes link.

Create the A record

To map an A record to an app, App Service requires two DNS records:

  • An A record to map to the app’s IP address.
  • TXT record to map to the app’s default hostname <app_name>.azurewebsites.net. App Service uses this record only at configuration time, to verify that you own the custom domain. After your custom domain is validated and configured in App Service, you can delete this TXT record.

For the contoso.com domain example, create the A and TXT records according to the following table (@ typically represents the root domain).

Record type Host Value
A @ IP address from Copy the app’s IP address
TXT @ <app_name>.azurewebsites.net

When the records are added, the DNS records page looks like the following example:

DNS records page

Enable the A record mapping in the app

Back in the app’s Custom domains page in the Azure portal, add the fully qualified custom DNS name (for example, contoso.com) to the list.

Select the + icon next to Add hostname.

Add host name

Type the fully qualified domain name that you configured the A record for, such as contoso.com.

Select Validate.

The Add hostname page is shown.

Make sure that Hostname record type is set to A record (example.com).

Select Add hostname.

Add DNS name to the app

It might take some time for the new hostname to be reflected in the app’s Custom domains page. Try refreshing the browser to update the data.

A record added

If you missed a step or made a typo somewhere earlier, you see a verification error at the bottom of the page.

Verification error

Map a wildcard domain

In the tutorial example, you map a wildcard DNS name (for example, *.contoso.com) to the App Service app by adding a CNAME record.

Access DNS records with domain provider

Note

You can use Azure DNS to configure a custom DNS name for your Azure Web Apps. For more information, see Use Azure DNS to provide custom domain settings for an Azure service.

Sign in to the website of your domain provider.

Find the page for managing DNS records. Every domain provider has its own DNS records interface, so consult the provider’s documentation. Look for areas of the site labeled Domain NameDNS, or Name Server Management.

Often, you can find the DNS records page by viewing your account information, and then looking for a link such as My domains. Go to that page and then look for a link that is named something like Zone fileDNS Records, or Advanced configuration.

The following screenshot is an example of a DNS records page:

Example DNS records page

In the example screenshot, you select Add to create a record. Some providers have different links to add different record types. Again, consult the provider’s documentation.

Note

For certain providers, such as GoDaddy, changes to DNS records don’t become effective until you select a separate Save Changes link.

Create the CNAME record

Add a CNAME record to map a wildcard name to the app’s default hostname (<app_name>.azurewebsites.net).

For the *.contoso.com domain example, the CNAME record will map the name * to <app_name>.azurewebsites.net.

When the CNAME is added, the DNS records page looks like the following example:

Portal navigation to Azure app

Enable the CNAME record mapping in the app

You can now add any subdomain that matches the wildcard name to the app (for example, sub1.contoso.com and sub2.contoso.com match *.contoso.com).

In the left navigation of the app page in the Azure portal, select Custom domains.

Custom domain menu

Select the + icon next to Add hostname.

Add host name

Type a fully qualified domain name that matches the wildcard domain (for example, sub1.contoso.com), and then select Validate.

The Add hostname button is activated.

Make sure that Hostname record type is set to CNAME record (www.example.com or any subdomain).

Select Add hostname.

Add DNS name to the app

It might take some time for the new hostname to be reflected in the app’s Custom domains page. Try refreshing the browser to update the data.

Select the + icon again to add another hostname that matches the wildcard domain. For example, add sub2.contoso.com.

CNAME record added

Edit the web.config using Kudu Console

There are two ways to access Kudu:

  1. Simply modify your website URL and by adding scm to it. If you site is http://mysite.azurewebsites.net/, then the root URL of the Kudu service is https://mysite.scm.azurewebsites.net/. Note the added scm token.
  2. Using the Azure Portal. First Navigate to your Web App, Select Tools -> Kudu -> Go:

launch Kudu from azure portal

How to View, Add, Edit, and Remove files in Azure Web App using Kudu

Finally this post was about how you actually view, edit, add, and remove files from the Web App. Once you have your Kudu service Dashboard open you will see some basic information and links for more complex tasks:

Kudu home page

View Current Files

View current files in your application by Clicking on Debug Console -> CMD:

Kudu view files

Once you are viewing the folder structure you can get to your application home directory by clicking the site folder:

Kudu site folder

 

Edit Files

To edit a file click the pencil icon:

launch Kudu from azure portal

Locate the web.config (or create it) and change the text to the following:

Replace <<appdomain>> with the domain you wish to redirect to.

 

Update Conference Prague

Featured

I have been selected to speak at Update Conference Prague during 

  •  Enable IoT with Edge Computing and Machine Learning
  • Virtual Reality and IoT – Interacting with the changing world

Enable IoT with Edge Computing and Machine Learning

Being able to run compute cycles on local hardware is a practice predating silicon circuits. Mobile and Web technology has pushed computation away from local hardware and onto remote servers. As prices in the cloud have decreased, more and more of the remote servers have moved there. This technology cycle is coming full circle with pushing the computation that would be done in the cloud down to the client. The catalyst for the cycle completing is latency and cost. Running computations on local hardware softens the load in the cloud and reduces overall cost and architectural complexity.

The difference now is how the computational logic is sent to the device. As of now, we rely on app stores and browsers to deliver the logic the client will use. Delivery mechanisms are evolving into writing code once and having the ability to run that logic in the cloud and push that logic to the client through your application and have that logic run on the device. In this presentation, we will look at how to accomplish this with existing Azure technologies and how to prepare for upcoming technologies to run these workloads.

Virtual Reality and IoT – Interacting with the changing world

Using IoT Devices, powered by Windows 10 IoT and Raspbian, we can collect data from the world surrounding us. That data can be used to create interactive environments for mixed reality, augmented reality, or virtual reality. To move the captured data from the devices to the interactive environment, the data will travel through Microsoft’s Azure. First it will be ingested through the Azure IoT Hub which provides the security, bi-directional communication, and input rates needed for the solution. We will move the data directly from the IoT Hub to an Azure Service Bus Topic. The Topic allows for data to be sent to every Subscription listening for the data that was input. Azure Web Apps subscribe to the Topics and forward the data through a SignalR Hub that forwards the data to a client. For this demo, the client is a Unity Application that creates a Virtual Reality simulation showcasing that data.

Once finished with this introduction to these technologies, utilizing each component of this technology stack should be approachable. Before seeing the pieces come together, the technologies used in this demonstration may not seem useful to a developer. When combined, they create a powerful tool to share nearly unlimited amounts of incoming data across multiple channels.

WordPress iFrame using Azure

There was a need to host some javascript in a WordPress page due to how sessionize embeds speaker sessions. Due to WordPress’ limitations on javascript usage, the script could not be used in the page. To bypass this limitation, an Azure website can host the script; and then be used as an iFrame inside the WordPress page. To accomplish this requires the following steps:

  • Create an Azure Website
  • Change the page to include the script
  • Host the script as an iFrame in WordPress page

Create an Azure Website

Azure Web Apps provides a highly scalable, self-patching web hosting service. This quickstart shows how to deploy a basic HTML+CSS site to Azure Web Apps. You’ll complete this quickstart in Cloud Shell, but you can also run these commands locally with Azure CLI.

Home page of sample app

If you don’t have an Azure subscription, create a free account before you begin.

Open Azure Cloud Shell

Azure Cloud Shell is a free, interactive shell that you can use to run the steps in this article. Common Azure tools are preinstalled and configured in Cloud Shell for you to use with your account. Just select the Copy button to copy the code, paste it in Cloud Shell, and then press Enter to run it. There are a few ways to open Cloud Shell:

Select Try It in the upper-right corner of a code block. Cloud Shell in this article
Open Cloud Shell in your browser. https://shell.azure.com/bash
Select the Cloud Shell button on the menu in the upper-right corner of the Azure portal. Cloud Shell in the portal

Install web app extension for Cloud Shell

To complete this quickstart, you need to add the az web app extension. If the extension is already installed, you should update it to the latest version. To update the web app extension, type az extension update -n webapp.

To install the webapp extension, run the following command:

az extension add -n webapp

When the extension has been installed, the Cloud Shell shows information to the following example:

The installed extension 'webapp' is in preview.

Download the sample

In the Cloud Shell, create a quickstart directory and then change to it.

mkdir quickstart

cd quickstart

Next, run the following command to clone the sample app repository to your quickstart directory.

git clone https://github.com/Azure-Samples/html-docs-hello-world.git

Create a web app

Change to the directory that contains the sample code and run the az webapp up command.

In the following example, replace <app_name> with a unique app name.

cd html-docs-hello-world

az webapp up -n <app_name>

The az webapp up command does the following actions:

  • Create a default resource group.
  • Create a default app service plan.
  • Create an app with the specified name.
  • Zip deploy files from the current working directory to the web app.

This command may take a few minutes to run. While running, it displays information similar to the following example:

{
  "app_url": "https://<app_name>.azurewebsites.net",
  "location": "Central US",
  "name": "<app_name>",
  "os": "Windows",
  "resourcegroup": "appsvc_rg_Windows_CentralUS ",
  "serverfarm": "appsvc_asp_Windows_CentralUS",
  "sku": "FREE",
  "src_path": "/home/username/quickstart/html-docs-hello-world ",
  < JSON data removed for brevity. >
}

Make a note of the resourceGroup value. You need it for the clean up resources section.

Browse to the app

In a browser, go to the Azure web app URL: http://<app_name>.azurewebsites.net.

The page is running as an Azure App Service web app.

Sample app home page

Congratulations! You’ve deployed your first HTML app to App Service.

Change the page to include the script

In the Cloud Shell, type nano index.html to open the nano text editor. Change the body of the app to include only the javascript tag you need.

Save your changes and exit nano. Use the command ^O to save and ^X to exit.

You’ll now redeploy the app with the same az webapp up command.

az webapp up -n <app_name>

Once deployment has completed, switch back to the browser window that opened in the Browse to the app step, and refresh the page.

Updated sample app home page

 

Host the script as an iFrame in WordPress page

In your WordPress page, add the following text in square brackets – iframe src=”https://<app_name>.azurewebsites.net/” where app_name is the name of the application you created in Azure.

MVP Renewal

Proudly, I will be entering my second year as a Microsoft MVP. This will be under the Microsoft Azure category again. Moving forward, I look forward to doing a large amount of work and training with Azure Edge and Azure ML. Specifically, I look forward to working on the Scry Unlimited and West World of Warcraft projects. To contact me for for your project, please visit the contact page.

As a start, on 7/2/2018 I will be presenting AI on the Edge at the Atlanta Intelligent Devices user group. Following that up I will be speaking at events around the country and hopefully internationally. In addition to my normal speaking on Mobile, Cloud, and Edge; I will be adding Machine Learning and Artificial Intelligence specifically focusing on the integration with Edge and Mobile computing. If you are looking for a speaker, check out my speaker page and fill out the form.

Finally, I am still putting together events in Atlanta. If you would like to participate in any of the following events, just follow their links or message me on Twitter:

TechBash 2018

This year I will be presenting Enable IoT with Edge Computing and Machine Learning at TechBash. Here is the outline:

Being able to run compute cycles on local hardware is a practice predating silicon circuits. Mobile and Web technology has pushed computation away from local hardware and onto remote servers. As prices in the cloud have decreased, more and more of the remote servers have moved there. This technology cycle is coming full circle with pushing the computation that would be done in the cloud down to the client. The catalyst for the cycle completing is latency and cost. Running computations on local hardware softens the load in the cloud and reduces overall cost and architectural complexity.

The difference now is how the computational logic is sent to the device. As of now, we rely on app stores and browsers to deliver the logic the client will use. Delivery mechanisms are evolving into writing code once and having the ability to run that logic in the cloud and push that logic to the client through your application and have that logic run on the device. In this presentation, we will look at how to accomplish this with existing Azure technologies and how to prepare for upcoming technologies to run these workloads.

 

Music City Code – IoT with Mobile

This year I will be at Music City Code presenting Configure, Control, and Manage IoT with Mobile.

Configure, Control, and Manage IoT with Mobile

Abstract

The internet of things allows for communication with devices through various means (without touch, mouse, keyboard, or a screen). Mobile devices give users a dynamic interactive experience with these devices by communicating over several different wireless protocols or through the cloud. In this presentation, we will see how to use Xamarin to create a cross platform mobile application to control devices of all shapes and sizes. After this presentation, attendees should be able to create a basic mobile application and have that application communicate with peripherals over Bluetooth and the cloud.

Description

This presentation is to showcase creating mobile applications with Xamarin and how those applications can interact with both off the shelf and with custom hardware. First, we will create a Xamarin Forms application; for iOS, Android, and Windows; that will interact with both Microsoft Azure and Bluetooth Low Energy to create an interactive experience with the hardware and the cloud. To get a better understanding, we will discuss mobile communication with the cloud and hardware to get a picture of how mobile can act as a bridge between the two.

 

IRIS Conference

April 14th is the Integrative Research and Ideas Symposium (IRIS) hosted by the UGA Graduate-Professional Student Association. I will be speaking on three separate topics at the event:

  • Virtual Reality and IoT – Interacting with the Changing World
  • Enable IoT with Edge Computing and Machine Learning
  • Alternative Device Interfaces and Machine Learning

More than that though I look forward to hearing about the innovations and research provided by the graduate students and professionals at UGA. Here is their synopsis of IRIS:

The UGA Graduate-Professional Student Association is proud to announce IRIS 2018, a unique and exciting opportunity for students and other researchers from throughout the UGA community. 

This initiative’s focus on community-building, cross-pollination of ideas, transferrable skills, and service will:

  • Provide an excellent opportunity to enhance research communication skills and present research to an interdisciplinary audience. 
  • Expose students to cutting-edge scholarship, industry professionals, and rich professional development opportunities.
  • Help attendees refine the content and language of their C.V.’s and resumés through career workshops. 
  • Encourage shared scholarship, research, and service.
  • Equip attendees with new knowledge and skills which can strengthen teaching, learning, and career outcomes. 
  • Empower attendees to translate skills and research interests into career competencies. 

Azure Global Bootcamp Atlanta

This year will be the 4th annual Azure Global Bootcamp in Atlanta. If you don’t know about Azure Global Bootcamp here is their snippet:

Welcome to Global Azure Bootcamp! All around the world user groups and communities want to learn about Azure and Cloud Computing!

On April 21, 2018, all communities will come together once again in the sixth great Global Azure Bootcamp event! Each user group will organize their own one day deep dive class on Azure the way they see fit and how it works for their members. The result is that thousands of people get to learn about Azure and join together online under the social hashtag #GlobalAzure!

Join hundreds of other organizers to help out and be part of the experience! Check out the different locations worldwide and if there is no location near you, why not organize one?

I will be leading off the IoT track after the Keynote. All around there is an amazing line up of speakers and it looks to be a great experience for both developers and decision makers. There are a limited number of seats so don’t waste time waiting to sign up.

CodeStock

I’m proud to be presenting Alternative Device Interfaces and Machine Learning at CodeStock this year. With AI becoming more and more ubiquitous, it is important to note the effect on a user’s experience. This presentation is meant to show how to create modern applications using machine learning provided by a third party and showcase what some third parties provide.

In this presentation, we will look at the how users interface with machines without the use of touch. These different types of interaction have their benefits and pitfalls. To showcase the power of these user interactions we will explore: Voice commands with mobile applications, Speech Recognition, and Computer Vision. After this presentation, attendees will have the knowledge to create applications that can utilize voice, video, and machine learning.

Users use voice (Alexa, Cortana, Google Now) or video as a mode of interaction with applications. More than a fad, this is a natural interface for users and is becoming more and more common with the ever-decreasing size of hardware.

Different types of interaction have their benefits and pitfalls. To showcase the power of these user interactions we will explore: Voice commands with two app types: UWP and Xamarin Forms (iOS and Android). Speech Recognition with Cognitive Services: Verifying the speaker with Speaker Recognition API. Computer Vision with Cognitive Services: Verifying a user with Face API.

By utilizing UWP, Xamarin, and Cognitive services; a device with the ultimate in customization for user interactions will be created. Come and see how!

Storing Event Data in Elastic Search

There was a CPU and network issue when the hosts uploaded data directly from the client to Elastic Search.  To allow for the same data load without the elastic overhead running on the client the following architecture was used:

  • Hosts use Event Hubs to upload the telemetry data
  • Consume Event Hub data with Stream Analytics
  • Output Stream Analytics query to Azure Function
  • Azure Function to upload output to Elastic Search

Event Hub

To start, the hosts needed an Event Hub to upload the data. For other projects Azure IoT Hub can be used due to Stream Analytics being able to ingest both. Event Hub was chosen so that each client would not need to provision as a device.

Create an Event Hubs namespace

  1. Log on to the Azure portal, and click Create a resource at the top left of the screen.
  2. Click Internet of Things, and then click Event Hubs.
  3. In Create namespace, enter a namespace name. The system immediately checks to see if the name is available.
  4. After making sure the namespace name is available, choose the pricing tier (Basic or Standard). Also, choose an Azure subscription, resource group, and location in which to create the resource.
  5. Click Create to create the namespace. You may have to wait a few minutes for the system to fully provision the resources.
  6. In the portal list of namespaces, click the newly created namespace.
  7. Click Shared access policies, and then click RootManageSharedAccessKey.
  8. Click the copy button to copy the RootManageSharedAccessKey connection string to the clipboard. Save this connection string in a temporary location, such as Notepad, to use later.

Create an event hub

  1. In the Event Hubs namespace list, click the newly created namespace.
  2. In the namespace blade, click Event Hubs.
  3. At the top of the blade, click Add Event Hub.
  4. Type a name for your event hub, then click Create.

Your event hub is now created, and you have the connection strings you need to send and receive events.

Stream Analytics

Create a Stream Analytics job

  1. In the Azure portal, click the plus sign and then type STREAM ANALYTICS in the text window to the right. Then select Stream Analytics job in the results list.Create a new Stream Analytics job
  2. Enter a unique job name and verify the subscription is the correct one for your job. Then either create a new resource group or select an existing one on your subscription.
  3. Then select a location for your job. For speed of processing and reduction of cost in data transfer selecting the same location as the resource group and intended storage account is recommended.Create a new Stream Analytics job details

    Note

    You should create this storage account only once per region. This storage will be shared across all Stream Analytics jobs that are created in that region.

  4. Check the box to place your job on your dashboard and then click CREATE.job creation in progress
  5. You should see a ‘Deployment started…’ displayed in the top right of your browser window. Soon it will change to a completed window as shown below.job creation in progress

Create an Azure Stream Analytics query

After your job is created it’s time to open it and build a query. You can easily access your job by clicking the tile for it.

Job tile

In the Job Topology pane click the QUERY box to go to the Query Editor. The QUERY editor allows you to enter a T-SQL query that performs the transformation over the incoming event data.

Query box

Create data stream input from Event Hubs

Azure Event Hubs provides highly scalable publish-subscribe event ingestors. An event hub can collect millions of events per second, so that you can process and analyze the massive amounts of data produced by your connected devices and applications. Event Hubs and Stream Analytics together provide you with an end-to-end solution for real-time analytics—Event Hubs let you feed events into Azure in real time, and Stream Analytics jobs can process those events in real time. For example, you can send web clicks, sensor readings, or online log events to Event Hubs. You can then create Stream Analytics jobs to use Event Hubs as the input data streams for real-time filtering, aggregating, and correlation.

The default timestamp of events coming from Event Hubs in Stream Analytics is the timestamp that the event arrived in the event hub, which is EventEnqueuedUtcTime. To process the data as a stream using a timestamp in the event payload, you must use the TIMESTAMP BY keyword.

Consumer groups

You should configure each Stream Analytics event hub input to have its own consumer group. When a job contains a self-join or when it has multiple inputs, some input might be read by more than one reader downstream. This situation impacts the number of readers in a single consumer group. To avoid exceeding the Event Hubs limit of five readers per consumer group per partition, it’s a best practice to designate a consumer group for each Stream Analytics job. There is also a limit of 20 consumer groups per event hub. For more information, see Event Hubs Programming Guide.

Configure an event hub as a data stream input

The following table explains each property in the New input blade in the Azure portal when you configure an event hub as input.

Property Description
Input alias A friendly name that you use in the job’s query to reference this input.
Service bus namespace An Azure Service Bus namespace, which is a container for a set of messaging entities. When you create a new event hub, you also create a Service Bus namespace.
Event hub name The name of the event hub to use as input.
Event hub policy name The shared access policy that provides access to the event hub. Each shared access policy has a name, permissions that you set, and access keys.
Event hub consumer group (optional) The consumer group to use to ingest data from the event hub. If no consumer group is specified, the Stream Analytics job uses the default consumer group. We recommend that you use a distinct consumer group for each Stream Analytics job.
Event serialization format The serialization format (JSON, CSV, or Avro) of the incoming data stream.
Encoding UTF-8 is currently the only supported encoding format.
Compression (optional) The compression type (None, GZip, or Deflate) of the incoming data stream.

When your data comes from an event hub, you have access to the following metadata fields in your Stream Analytics query:

Property Description
EventProcessedUtcTime The date and time that the event was processed by Stream Analytics.
EventEnqueuedUtcTime The date and time that the event was received by Event Hubs.
PartitionId The zero-based partition ID for the input adapter.

For example, using these fields, you can write a query like the following example:

SELECT
    EventProcessedUtcTime,
    EventEnqueuedUtcTime,
    PartitionId
FROM Input

Azure Functions (In Preview)

Azure Functions is a serverless compute service that enables you to run code on-demand without having to explicitly provision or manage infrastructure. It lets you implement code that is triggered by events occurring in Azure or third-party services. This ability of Azure Functions to respond to triggers makes it a natural output for an Azure Stream Analytics. This output adapter allows users to connect Stream Analytics to Azure Functions, and run a script or piece of code in response to a variety of events.

Azure Stream Analytics invokes Azure Functions via HTTP triggers. The new Azure Function Output adapter is available with the following configurable properties:

Property Name Description
Function App Name of your Azure Functions App
Function Name of the function in your Azure Functions App
Max Batch Size This property can be used to set the maximum size for each output batch that is sent to your Azure Function. By default, this value is 256 KB
Max Batch Count As the name indicates, this property lets you specify the maximum number of events in each batch that gets sent to Azure Functions. The default max batch count value is 100
Key If you want to use an Azure Function from another subscription, you can do so by providing the key to access your function

Note that when Azure Stream Analytics receives 413 (http Request Entity Too Large) exception from Azure function, it reduces the size of the batches it sends to Azure Functions. In your Azure function code, use this exception to make sure that Azure Stream Analytics doesn’t send oversized batches. Also, make sure that the max batch count and size values used in the function are consistent with the values entered in the Stream Analytics portal.

Also, in a situation where there is no event landing in a time window, no output is generated. As a result, computeResult function is not called. This behavior is consistent with the built-in windowed aggregate functions.

Query

The query itself if basic for now. There is no need for the advanced query features of Stream Analytics for the host data at the moment however it will be used later for creating workflows for spawning and reducing hosts.

Currently, the query will batch the data outputs from event hub every second. This is simple to accomplish this using the windowing functions provided by Stream Analytics. In the Westworld of Warcraft host query, a tumbling window batches the data every one second. The query looks as follows:

SELECT
    Collect()
INTO
    ElasticUploadFunction
FROM
    HostIncomingData
GROUP BY TumblingWindow(Duration(second, 1), Offset(millisecond, -1))

 

Azure Function

Create a function app

You must have a function app to host the execution of your functions. A function app lets you group functions as a logic unit for easier management, deployment, and sharing of resources.

  1. Click Create a resource in the upper left-hand corner of the Azure portal, then select Compute > Function App.Create a function app in the Azure portal
  2. Use the function app settings as specified in the table below the image.Define new function app settings
    Setting Suggested value Description
    App name Globally unique name Name that identifies your new function app. Valid characters are a-z, 0-9, and -.
    Subscription Your subscription The subscription under which this new function app is created.
    Resource Group myResourceGroup Name for the new resource group in which to create your function app.
    OS Windows Serverless hosting is currently only available when running on Windows. For Linux hosting, see Create your first function running on Linux using the Azure CLI.
    Hosting plan Consumption plan Hosting plan that defines how resources are allocated to your function app. In the default Consumption Plan, resources are added dynamically as required by your functions. In this serverless hosting, you only pay for the time your functions run.
    Location West Europe Choose a region near you or near other services your functions access.
    Storage account Globally unique name Name of the new storage account used by your function app. Storage account names must be between 3 and 24 characters in length and may contain numbers and lowercase letters only. You can also use an existing account.
  3. Click Create to provision and deploy the new function app. You can monitor the status of the deployment by clicking the Notification icon in the upper-right corner of the portal.Define new function app settingsClicking Go to resource takes you to your new function app.

Elastic Search

Now the data is in Elastic Search which if the instructions in the Elastic Search setup post were followed, should be accessible from the Kibana endpoint.