Skip to main content

Send images to Azure Blob Storage

In this how-to guide we configure a camera to send images to Azure Blob Storage.

architecture

This application consists of the following Azure resources.

  • An API Management instance
  • A storage account with a blob container

The camera will send images to the blob container via an API Management endpoint. The API Management resource receives a POST request containing the image from the camera. This request is transformed to a PUT request as this is required by the Azure storage REST API. The API Management uses a system-assigned managed identity to authenticate to Azure storage. The API Management endpoint is secured by a subscription key which is provided to the camera.

Prerequisites

  • A network camera from Axis Communications (how-to guide has been verified to work on a camera with firmware version >=9.80.3.1)

No command-line interface is needed to run this how-to guide even though command listings are present. For more information on the syntax we use for command listings, see the the command-line interface reference.

Instructions

The instructions are divided into two parts. The first part covers deploying the Azure resources and the second part covers configuring the camera.

Deploy Azure resources

Let's deploy the Azure resources receiving the images sent from a camera. Navigate to the Azure Portal by right-clicking the button below and open the link in a new tab.

Deploy to Azure

The template, main.bicep, is written in Bicep, a language created by Microsoft to define infrastructure as code. It will require you to set the following custom parameters.

  • Publisher Email - Email address that will receive all system notifications sent from the API-management resource.
  • Location - The location to deploy all resources in. Default value tells Azure to deploy resources to the location of the resource group.

Once the deployment is complete, navigate to the Outputs tab and take note of the endpoint value. We will use this endpoint in the next chapter when we configure the camera.

Outputs

Configure the camera

Now that the resources in Azure are ready to accept images, let's continue with configuring the camera to send them.

Navigate to the camera using your preferred web browser. In the user interface of the camera, select System -> Events. In this user interface we'll do all configuration, but first let's get an overview of the available tabs.

  • Rules - Here we'll create a rule that sends images to our Azure storage account
  • Recipients - Here we'll define where images are sent
  • Schedules - In this sample we'll use a schedule to define when a snapshot should be sent. If a schedule doesn't fit your specific use case, you can replace it with any event generated on the camera or even events generated by installed on the camera.

Let's start with Recipients. Select the tab and create a new recipient with the following settings. Leave the settings that aren't mentioned with their default values.

  • Name: Azure storage
  • Type: HTTPS
  • URL: Specify the endpoint you obtained in the first part of this how-to guide, e.g. https://image-upload-abcdefghijklm.azure-api.net?accessToken=abcdef1234567890abcdef1234567890.

Click the Save button.

Now let's navigate to the Schedules tab. In this sample we'll use a schedule to define when a snapshot should be send. Create a new schedule with the following settings.

  • Name: Every minute
  • Type: Pulse
  • Repeat every: 1 Minute

Click the Save button.

Now let's navigate to the Rules tab. Here we'll finally create a rule that combines the recipient and the schedule into a rule. Create a new rule with the following settings. Leave the settings that aren't mentioned with their default values.

  • Name: Images to Azure storage
  • Condition: Pulse
    • Pulse: Every Minute
  • Action: Send images through HTTPS
    • Recipient: Azure storage
    • Maximum images: 1

Click the Save button.

At this point the rule will become active and send a snapshot to Azure storage every minute. Navigate to your storage account in Azure Portal, select the container images, and within that container you will find the uploaded images.

Cleanup

To delete the deployed Azure services, including all images in the storage account, either use the Azure Portal to delete the resource group, or run the following CLI command:

Cleanup deployed resources
az group delete --name <resource group name>

The Azure API Management instance will be soft-deleted and remain known to Azure for 48 hours. This will prevent you from redeploying the application to a resource group with the same name. Please select a new name for the resource group, wait 48 hours or purge the instance using the Azure REST API.

Troubleshooting

This section will highlight some of the common problems one might encounter during this how-to guide.

No images are sent to the Azure storage account

If the camera is unable to successfully send images to the Azure storage account, please make sure that the following statements are true.

  • The camera is not behind a proxy. This how-to guide does not support a network topology where requests needs to traverse a proxy to reach the internet.

Disclaimer

Amazon Web Services, AWS and the Powered by AWS logo are trademarks of Amazon.com, Inc. or its affiliates. All other trademarks are the property of their respective owners, and we are not affiliated with, endorsed or sponsored by them or their affiliates.

As described in this document, you may be able to connect to, access and use third party products, web sites, example code, software or services (“Third Party Services”). You acknowledge that any such connection and access to such Third Party Services are made available to you for convenience only. Axis does not endorse any Third Party Services, nor does Axis make any representations or provide any warranties whatsoever with respect to any Third Party Services, and Axis specifically disclaims any liability or obligations with regard to Third Party Services. The Third Party Services are provided to you in accordance with their respective terms and conditions, and you alone are responsible for ensuring that you (a) procure appropriate rights to access and use any such Third Party Services and (b) comply with the terms and conditions applicable to its use.