Refresh IoT data from database in GeoJson format and display in Azure Maps.

Maciej Skuratowski 1 Reputation point
2023-02-06T11:11:49.1766667+00:00

Hi,

I would like to ask you how can I achieve refresh data on Azure Maps.

I have an IoT data in Azure SQL and I need to display those data in Azure Maps.

I'm looking for the best solution how to get data frequently (each 5 minutes) and refresh data on Azure Maps.

I was thinking to use Azure Data Factory which gets data from SQL, parse those data to GeoJson format (FeautreCollections) and then save data to Azure Blob Storage. Then WebApp can initialize Azure Maps datasource using URL.

What do you think about that solution? Is it a better solution?

Azure Maps
Azure Maps
An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
592 questions
{count} votes

2 answers

Sort by: Most helpful
  1. rbrundritt 15,311 Reputation points Microsoft Employee
    2023-02-06T17:33:24.39+00:00

    The best solution would depend on the following factors:

    • The size and complexity of your data. If you are working with a couple thousand individual points, then it's fairly easy, but if you are working with a lot of points (more than a few MB in size) then you will likely find the data download to be big and slow loading and need a more optimized loading/rendering method.
    • Frequency of updates to the map. 5 minutes in your case is fairly easy to achieve.

    If you are working with a smaller set of data (< a few MB), a simple webservice that grabs and converts the data on the fly and sends the response to the client would work fine. You can poll this service on a timer from the client. You could setup a caching mechanism if you plan on having a lot of end users.

    If you want to support higher frequency updates, then using something like SignalR would be a good option. Here is an example that shows real time updates of flights on a map. https://davetheunissen.github.io/Real_Time_Flight_Map/

    If you have large datasets (tens of MB or more), you will need to optimize the data for rendering. A common method used is to only load the data needed for the users viewport (area they are looking at on the map). This can be achieved in a couple of ways:

    • Create a webservice that takes in a bounding box and query all data within that bounding box. Get the map's bounding box view. Query every time the user moves the map. This is an OK solution for lower used apps, but not as optimized as it could be.
    • Break the data into tiles and load them in that way. Azure Maps supports both vector and raster tiles. Vector tiles are a newer format that is now widely being adopted. They are small and easy to load into the map, however, creating them can be a bit complex if you are new to it. Vector tiles can be generated on the fly as needed quickly, are easily cached, and can support crazy large data sets (Azure Maps serves all the base map road data globally in this format). Also, if you set an expires header on the tiles (say 5 minutes), the Azure Maps web SDK will automatically request new data when the tile expires. Here is some more information on vector tiles:
      https://learn.microsoft.com/en-us/azure/azure-maps/create-data-source-web-sdk#vector-tile-source http://richorama.github.io/2019/02/05/roll-your-own-vector-tile-service/

  2. rbrundritt 15,311 Reputation points Microsoft Employee
    2023-02-08T15:30:56.4933333+00:00

    Azure functions can be reliable with 3MB and larger. The lowest level version of Azure functions timesout after 5 minutes (can be adjusted to 10 mins), and the premium and dedicated versions default at a 30 min timeout but can have the timeout removed all together. Downloading a million rows of data from a database, converting it to GeoJSON and sending down to the user would normally be less than a minute unless you have a really complex heavy SQL query. At the same time, you likely wouldn't want the user to have to wait more than a minute in the worst case. So, Azure function is well suited for this scenario. If you are using this in a production environment where this service will be used regularly, I would recommend enabling the "Always on" feature of the service. This will prevent cold starts and ensure the service responds quickly for all the time.

    The Azure maps Data V2 API is mainly for the Azure Maps creator platform (indoor maps), and for uploading data used for rendering static maps. It would not be a good fit for your scenario at this time. I have been try to get that team to extend the capabilities of that service so that you could point it to a custom SQL database and it provide the exact kind of service you are looking for. I believe they are looking into this, but have no timeline on when/if it will be available.