Live Streaming with Microsoft Azure Media Services

We’ve seen how to setup OBS for live streaming, and how to send it to YouTube. This article is about how can set up your own live streaming using Microsoft Azure Media Services.

Prerequisites

You will need:

What we will do

Image for post
Image for post

We’ll create what is in the diagram. Everything in Azure lives inside your Azure account, and this is tied to an Azure subscription. Within your Azure account, you can have many different infrastructure and platform services. Resource Groups are a way to group these together. We’ll create a resource group that groups all of the things we create for our live stream. When you use Azure Media Services to live stream, you can also create a DVR or VOD asset. This needs to be stored somewhere, so we will create an Azure Storage account for this. The streaming itself happens within Azure Media Services, so we will create an Azure Media Service instance. The Azure Media Service Instance automatically creates an endpoint. This is the streaming input URL and you tell OBS to stream to this location. We will then create a channel, which is the entity that contains live events. Then we can create the live event itself and create a locator for it, which is the output. We then need to get that output out of Azure and we use a streaming endpoint to do so. The streaming endpoint can use a content delivery network (CDN) to deliver your stream more efficiently.

1. Login to the Azure Portal

Open a web browser and go to http://portal.azure.com and login with your Azure account. If you don’t have one, this is your opportunity to create one. You will see a screen like this.

Image for post
Image for post
Microsoft Azure Portal

2. Create Azure Media Service

The portal is pretty user-friendly and will prompt you to create whatever it needs as you go through it. We could go through and create the resource group and storage account on our own, but instead we’ll do so via the Azure Media Service creation workflow. In the search box, type “media” and you will see “Media services” highlighted under Services.

Image for post
Image for post
Search for “media” to find Azure Media Services.

Now click the blue “Create media service” button.

Image for post
Image for post
Use the blue button to start the media service creation workflow.

This starts the media service creation workflow. Required fields are prefixed with a red asterisk. You will typically see a green checkmark to the right of the field if you have entered valid data. If you see a red cross, then either the data you’ve chosen is not unique or it contains a character that is not supported.

Image for post
Image for post
Enter required information for your media service.

You need to specify an Account Name for the media service (this is not the same as the Azure account; it is not case-sensitive and cannot include special characters).

The Subscription field should already be filled out. If you have multiple subscriptions associated with your Azure account, choose the appropriate one.

Under Resource Group, select the “Create New” radio button, and enter a name for your resource group.

The Location will default to a value, in my case “West US”.

Image for post
Image for post
Click the > symbol to create a storage account.

Finally, you will see the “Storage Account” field. Click the right arrow, which will allow you to choose a storage account. Since you probably don’t have one, you will choose “Create new”, and type the name of your storage account in the Name field.

Image for post
Image for post
Choose a unique name for the storage account.

When you press OK, you will be taken back to the Media service creation screen, and you can now press Create.

Image for post
Image for post
Click Create to deploy the media service.

You will then see a popup message informing you that deployment is in progress.

Image for post
Image for post
Popups provide notification of activity.

If you click the bell icon on the near the top of the browser window, you can open up the notifications to check on the progress of deployments. In this case, you will see that the deployment succeeded.

Image for post
Image for post
The Notifications page shows the notification history, and lets you immediately go to resources that have just been created.

Press the “Go to resource” button to continue to the Media Services console. This provides information about what is going on with the media service that you just created, and lets you perform a variety of operations.

Image for post
Image for post
Main media service overview screen.

3. Create the Channel

Under Media Services in the right column, click “Live streaming”. This enables you to create a channel.

Image for post
Image for post
Create live streaming channel.

Click “Custom create” because we want to do live encoding and packaging and not just passthrough. This launches the channel creation workflow.

Image for post
Image for post
Channel creation workflow.

Click on the right arrow of “Settings” to configure the basic settings. You need to change the “Encoding type” to “Live Encoding” and specify a Name for your channel. Then press OK.

Image for post
Image for post
Filling out the basic channel settings.

Now you will be shown the channel ingest settings. There’s nothing to change here because you have an RTMP output from OBS, so you can just press OK to continue.

Image for post
Image for post
Channel ingest settings.

There is nothing to change on the Preview page, so just press OK to continue.

Image for post
Image for post
Channel preview settings.

The Encoding page is the final one and you should leave the Encoding preset to the “Default 720p” value. Press OK to continue.

Image for post
Image for post
Channel encoding settings.

You will see green check marks next to all four steps, and you can now press the Create button to create your channel.

Once again, you’ll see a notification message about the channel being created. You’ll then see your channel and a field containing the ingest URL. Things will continue to happen behind the scenes as the channel is provisioned and started, and you’ll see the status change from Stopped to Started.

Image for post
Image for post
Channel starting up.

4. Create the Live Event

We’ve created the media service and the channel. Now we need to create the live event. Click the channel that you just created listed under “Channel Name” to bring up the channel page.

Image for post
Image for post
Channel page.

Since we just want to start live streaming immediately, click the “Go Live” button towards the top of the screen — it has a little globe icon next to it. This kicks off the live event creation workflow and we’ll see corresponding notifications. You will also see the live event (called “default”) listed at the bottom of the screen, and eventually its status will change to “Running”.

Image for post
Image for post
Live event called “default” created.

5. Create Streaming Endpoint

Now you have a live event running in the channel that you created within the Azure Media Service. You can get video in, but you can’t get video out until you create one or more locators. Click on the live event under “Live events” that you just created to show more information about it.

Sometimes, this page does not open and you need to refresh the browser window and navigate back to the live event screen. When the live event information loads, it should look like this.

Image for post
Image for post
Live event page.

You will notice that while the live event is running, there is a red exclamation point next to the “Locator Type” called Streaming. Click it to configure the streaming endpoint.

Image for post
Image for post
Locator details page.

The message in the shaded box says that a streaming endpoint must be running. This is how video is going to leave Azure and get to your viewers. Click on this shaded box.

Image for post
Image for post
Streaming endpoint details.

A streaming endpoint is created for you with some default settings. One of these is to use a CDN for delivery. You can disable this if you want by clicking the “Disable CDN” button near the top, but we’ll leave it enabled for now.

Start the streaming endpoint by click the Start button near the top. Because CDN usage is selected by default, you will get a notification about CDN provisioning and propagation. Click Yes to continue.

Image for post
Image for post
Confirmation to start streaming endpoint.

6. Start Input Stream

While the streaming endpoint is being started, now is a good time to go into OBS and setup the input stream.

Scroll to the far left in your browser window and you will get all the way back to the Media Service page (you can also get to this by looking at the media service page and clicking on live streaming.) Grab the Ingest URL by clicking the clipboard icon to the far right of the field.

Image for post
Image for post
Ingest URL on media service screen.

7. Configure OBS

Now go into the Settings menu of OBS and navigate to Stream. Paste the URL that you just copied into the URL field and type “default” in the “Stream key” field, then press OK.

Image for post
Image for post
Stream settings in OBS.

Back on the OBS main screen, press “Start Streaming” — make sure you have something setup in OBS to stream or you will just be outputting a black screen.

Image for post
Image for post
View of live stream in OBS.

8. Test the Live Stream

Now go back into your browser, and scroll to the right until you get to the Locator details page.

Image for post
Image for post
List of available stream formats.

You will see four streaming endpoints, each for different streaming protocols. You can click the “Watch” button on the Live Event page to bring up an embedded player (press the play button to start playback!) On the screen below, you can see the OBS window, the Azure console window, the native IINA player app playing the HLSv4 stream and a dash.js reference player. Note that the OBS stream will be ahead of all of the others. The DASH and HLS outputs should only have a few seconds difference.

Image for post
Image for post
Testing on a single machine: OBS, Azure Media Services configuration, dash.js player, IINA player app (from lower right going clockwise.)

You can use these URLs for playback in the appropriate player on different devices.

9. Shutting it Down

Don’t forget to shut things off or delete them when you are done. Keeping channels running incurs costs. You can either delete the resource group, which will destroy all of the resources, or if you’re going to do more streaming, you can simply stop anything that is running. You can use the Dashboard view to see what resources are present in your account.

Image for post
Image for post
Resource group view.

Written by

Builder of media technology services and a videography, cinematography, photography, gadget, IoT, AI, auto and aviation geek.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store