Get Started
This 15-minute tutorial will show you how to start using the Spotflow IoT Platform. You'll simulate a weather station that measures the temperature and humidity in your room every few seconds. We'll show you how to:
- Create a new Workspace
- Register a Device
- Visualize current Device telemetry in Grafana
- View stored telemetry records
Contact us if you encounter any problems; we'll be happy to help!
Requirements
- PC or any other machine with either Linux or Windows.
- One of the following:
- Python of version ≥ 3.7
- C compiler (examples use GCC with Make on Linux and Visual Studio 2022 on Windows)
- If you are not registered to the Spotflow IoT Platform yet, Sign Up. See supported sign-up options.
Let's start!
1. Create Workspace
A Workspace is a container where you put all the Devices and other assets relevant to a certain task. Use either the Portal, CLI, or API to create a new one:
- Portal
- CLI
- API
Login to the Spotflow IoT Platform Portal and follow the instructions:
On the Overview page of the Portal, click Create new workspace.
Enter a short and fitting Display Name for the Workspace, such as "Test Workspace". You can change the name later. Click Create.
After the Workspace is created, you'll be redirected to the Workspace Details page. The Workspace is also selected as the current one in the upper right corner of the page. Most importantly, all the links in the left menu are now enabled, and you can use all the Platform features.
You can use our CLI to manage the Platform in a more automatable way. Install it and run the following command:
spotf login
The CLI will open the browser and ask you to log in and confirm that you want to use the CLI. After you do so, the CLI will produce output similar to the following:
LoginStatusMessage: You have been successfully logged in.
Instance: eu1.spotflow.io
InstanceUri: https://eu1.spotflow.io
Email: john.doe@example.com (557e43b8-ebd8-4494-87e9-3e5dc68297fa)
Default
├── Instance: eu1.spotflow.io
├── SubjectId: john.doe@example.com (557e43b8-ebd8-4494-87e9-3e5dc68297fa
└── Workspace: No workspace selected
Trial
├── IsExpired: false
└── ExpirationTime: 2023-10-16 11:20:25
Use the following command to create a new Workspace:
spotf workspace create --name "Test Workspace"
The CLI will confirm the creation and display the Workspace details:
WorkspaceId: 52aefb52-6ed8-453e-83e9-0048511f7ce9
DisplayName: Test Workspace
CreatedAt: 2023-10-02T11:20:51.2869299+00:00
CreatedBy: 557e43b8-ebd8-4494-87e9-3e5dc68297fa
State: Enabled
WorkspaceDefaultStorage
├── SubscriptionId: 894aad74-64af-45ac-b030-57d3c9feb24f
├── ResourceGroupName: spotf-workspaces-data-eu1-rg
└── StorageAccountName: ygemvpvpam2b9nwtt9gwmpzk
All the following commands will use this Workspace.
You can call our API directly without using the CLI, which might be useful for more fine-tuned integrations with your system. First, obtain a short-term API access token from the Portal:
Click the user icon in the top right corner of the page.
Open the link Preferences.
Click Copy token to copy the API access token to your clipboard. Note it somewhere so that you can use it in the following steps.
Replace the placeholder <Your API Access Token>
with your API access token and run the following command to create a Workspace:
- cURL
- PowerShell
curl -X POST 'https://api.eu1.spotflow.io/workspaces' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <Your API Access Token>' \
-d '{"displayName": "Test Workspace"}'
(Invoke-WebRequest -Method Post -Uri 'https://api.eu1.spotflow.io/workspaces' `
-Headers @{
'Content-Type' = 'application/json'
'Accept' = 'application/json'
'Authorization' = 'Bearer <Your API Access Token>'
} `
-Body '{"displayName": "Test Workspace"}').Content
The API will confirm the creation and display the Workspace details (the JSON is formatted for better readability):
{
"workspaceId": "52aefb52-6ed8-453e-83e9-0048511f7ce9",
"displayName": "Test Workspace",
"createdAt": "2023-10-02T11:20:51.2869299+00:00",
"createdBy": "557e43b8-ebd8-4494-87e9-3e5dc68297fa",
"state": "Enabled",
"workspaceDefaultStorage": {
"subscriptionId": "894aad74-64af-45ac-b030-57d3c9feb24f",
"resourceGroupName": "spotf-workspaces-data-eu1-rg",
"storageAccountName": "ygemvpvpam2b9nwtt9gwmpzk"
}
}
Note the value of the property workspaceId
somewhere so that you can use it in the following steps.
You can find more information about Users and Workspaces in the User Guide. See the reference of CLI and API for more details about the available commands and endpoints.
2. Configure Data Flow
You'll now configure the Platform to forward all the data from the Device to the integrated instance of Grafana:
- Portal
- CLI
- API
Open the link Data Flows in the left sidebar.
You'll see the list of Streams that are organized into Stream Groups. Select the Stream
default
in the Stream Groupdefault
.On the right side of the screen, you see the detailed configuration of the Stream. These options influence where the data are stored and how they are processed. Click the Egress tab.
The section Routes shows all the Egress Sinks where the Stream forwards the data it receives. The list is empty by default. Click Create new route.
Enter a machine-readable Name (allowed are only alphanumeric characters,
-
,_
, and.
) such asGrafana
. In the selection box Egress Sink, select Grafana. Click Save.Nice! Now you should see the newly created Egress Route in the list.
Supposing you have already installed the CLI and logged in, run the following command:
spotf stream egress-route create-or-update grafana --stream-group-name "default" --stream-name "default" --egress-route-name "Grafana"
The CLI will confirm the creation and display the Egress Route details:
info: Spotflow.IotPlatform.Cli.App.Commands.DataFlows.Streams.EgressRoutes.StreamEgressRouteCreateOrUpdateEventHubCommand[0]
Egress Route 'Grafana' for Stream 'default' in Stream Group 'default' created successfully.
Name: Grafana
WorkspaceId: 52aefb52-6ed8-453e-83e9-0048511f7ce9
StreamGroupName: default
StreamName: default
Properties
├── IsEnabled: true
├── EgressSinkName: Grafana
├── Config
└── Input: Messages
The following instructions expect that you have already obtained the API access token from the Portal and that you know the ID of the Workspace you want to use. If you don't know the Workspace ID, you can find it in the Portal under the link Workspaces in the left sidebar.
Replace the placeholders <Your Workspace ID>
and <Your API Access Token>
with your Workspace ID and API access token and run the following command to create a new Egress Route:
- cURL
- PowerShell
curl -X PATCH 'https://api.eu1.spotflow.io/workspaces/<Your Workspace ID>/stream-groups/default/streams/default/egress-routes/Grafana' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <Your API Access Token>' \
-d '{"properties": {"egressSinkName": "Grafana"}}'
(Invoke-WebRequest -Method Patch -Uri 'https://api.eu1.spotflow.io/workspaces/<Your Workspace ID>/stream-groups/default/streams/default/egress-routes/Grafana' `
-Headers @{
'Content-Type' = 'application/json'
'Accept' = 'application/json'
'Authorization' = 'Bearer <Your API Access Token>'
} `
-Body '{"properties": {"egressSinkName": "Grafana"}}').Content
The API will confirm the creation and display the Egress Route details:
{
"name": "Grafana",
"workspaceId": "<Your Workspace ID>",
"streamGroupName": "default",
"streamName": "default",
"version": 1,
"properties": {
"isEnabled": true,
"egressSinkName": "Grafana",
"config": {},
"input": "Messages"
}
}
The User Guide provides more information about how to send data to the Platform and process them further.
3. Create Provisioning Token
The process used to register a Device to the Platform is called Device Provisioning. To perform it, the Device needs a Provisioning Token. Let's create it:
- Portal
- CLI
- API
Open the link Devices in the left sidebar.
The list of all connected Devices opens. The Device will appear here after you register it to the Platform. Open the link Tokens in the left sidebar.
The list of Provisioning Tokens opens. Click Create new in the upper right corner.
Use the Recommended Registration Token Lifetime. Click Next.
Keep the default configuration of how Devices obtain their IDs. Click Next.
Enter an arbitrary name (e.g.,
Test Token
) and click Create.The newly created Provisioning Token appears at the bottom of the page. Click the copy icon on the right side to copy it to the clipboard. Note it somewhere so that you can use it in the next step.
Supposing you have already installed the CLI and logged in, run the following command:
spotf provisioning-token create --display-name "Test Token"
The CLI will confirm the creation and display the Provisioning Token details:
ProvisioningTokenId: 49ea58cf-6a87-413a-b8c4-e8dd1d364006
ProvisioningToken: CAEQAQ.ChIJLjh59NiNOU4RgC2QjaoFuRA.eYt-EUvBDsmhsF-s1TBR6B8dI2BtdIiwjOoGfPpLSVn9SC8n35nWi03d36XqZ2Yp9Caj6d6v8XTKIhQ6g0R731mIxNaNh2Gt-4zFccJsNV956IBmHYblUUHO1YcS-NsP
IssuedTime: 2023-10-23T12:50:17.9088245+00:00
RegistrationTokenLifetimeOverrideMode: Allowed
DeviceIdOverrideMode: DeviceAndTechnicianAllow
AllowInfiniteRegistrationTokenLifetime: false
MaxRegistrationTokenLifetime: 30d
Note the value following the label ProvisioningToken:
somewhere so you can use it in the next step.
The following instructions expect that you have already obtained the API access token from the Portal and that you know the Workspace ID.
Replace the placeholders <Your Workspace ID>
and <Your API Access Token>
with your Workspace ID and API access token and run the following command to create a new Provisioning Token:
- cURL
- PowerShell
curl -X POST 'https://api.eu1.spotflow.io/workspaces/<Your Workspace ID>/provisioning-tokens/create' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <Your API Access Token>' \
-d '{"displayName": "Test Token", "maxRegistrationTokenLifetime": "30.00:00:00", "registrationTokenLifetimeOverrideMode": "Allowed", "deviceIdOverrideMode": "DeviceAndTechnicianAllow", "allowInfiniteRegistrationTokenLifetime": false}'
(Invoke-WebRequest -Method Post -Uri 'https://api.eu1.spotflow.io/workspaces/<Your Workspace ID>/provisioning-tokens/create' `
-Headers @{
'Content-Type' = 'application/json'
'Accept' = 'application/json'
'Authorization' = 'Bearer <Your API Access Token>'
} `
-Body '{"displayName": "Test Token", "maxRegistrationTokenLifetime": "30.00:00:00", "registrationTokenLifetimeOverrideMode": "Allowed", "deviceIdOverrideMode": "DeviceAndTechnicianAllow", "allowInfiniteRegistrationTokenLifetime": false}').Content
The API will confirm the creation and display the Provisioning Token details:
{
"provisioningTokenId": "49ea58cf-6a87-413a-b8c4-e8dd1d364006",
"provisioningToken": "CAEQAQ.ChIJLjh59NiNOU4RgC2QjaoFuRA.eYt-EUvBDsmhsF-s1TBR6B8dI2BtdIiwjOoGfPpLSVn9SC8n35nWi03d36XqZ2Yp9Caj6d6v8XTKIhQ6g0R731mIxNaNh2Gt-4zFccJsNV956IBmHYblUUHO1YcS-NsP",
"issuedTime": "2023-10-23T12:50:17.9088245+00:00",
"maxRegistrationTokenLifetime": "30d",
"registrationTokenLifetimeOverrideMode": "Allowed",
"deviceIdOverrideMode": "DeviceAndTechnicianAllow",
"allowInfiniteRegistrationTokenLifetime": false
}
Note the value of the property provisioningToken
somewhere so that you can use it in the next step.
Learn more about Device Provisioning and management in the User Guide.
4. Gather Data from Device
The Device will now use the Provisioning Token to start a Provisioning Operation. After you approve it, the Device will finish the registration and start sending data to the Platform.
4.1. Use Device SDK
The Device SDK is available for Python and C:
- Python
- C
Install the recent Device SDK for Python using the following command:
pip install --upgrade spotflow-device
Paste the following code into a new file, or download it.
Replace the placeholder <Your Provisioning Token>
with your Provisioning Token and run the program.
import datetime
import json
import time
from spotflow_device import DeviceClient
# Connect to the Platform (starts Device Provisioning if the Device is not already registered)
client = DeviceClient.start(device_id="my-device", provisioning_token="<Your Provisioning Token>", db="spotflow.db")
# Create a sender to the default stream
sender = client.create_stream_sender(stream_group = "default-stream-group", stream = "default-stream")
for i in range(0, 60):
# Send and display the measured data
payload = json.dumps({
"timestamp": datetime.datetime.now().astimezone().isoformat(),
"temperatureCelsius": 21 + (i * 0.05),
"humidityPercent": 50 + (i * 0.1)
})
sender.send_message(payload.encode())
print(payload)
# Pause till next iteration
time.sleep(5)
DeviceClient.start
will display the following text:
Provisioning operation initialized, waiting for approval.
Operation ID: b170c9ab-961c-4c02-af88-d4287d9cea1f
Verification Code: jgcjtprw
After you approve the operation in the next step, the Device will start sending the data as short Messages.
Download the latest version of the library for your operating system and processor architecture:
Extract the archive to a directory of your choice.
The file examples/get_started.c
contains the following code:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "spotflow.h"
#ifdef _WIN32
#include <windows.h>
#define gmtime_r(timer, buf) gmtime_s(buf, timer)
#else
#include <unistd.h>
#define Sleep(x) usleep((x)*1000)
#endif
void show_last_error()
{
size_t error_size = SPOTFLOW_ERROR_MAX_LENGTH;
char* error_buffer = malloc(error_size);
spotflow_read_last_error_message(error_buffer, error_size);
printf("Error: %s\n", error_buffer);
free(error_buffer);
}
void send_data(spotflow_client_t* client)
{
spotflow_message_context_t* ctx;
spotflow_message_context_create(&ctx, "default-stream-group", "default-stream");
const size_t max_size = 1024;
char* msg = malloc(max_size);
for (int i = 0; i < 60; i++)
{
time_t now_ts = time(NULL);
struct tm now;
gmtime_r(&now_ts, &now);
double temperature = 21 + (i * 0.05);
double humidity = 50 + (i * 0.1);
snprintf(
msg, max_size,
"{\"timestamp\": \"%04d-%02d-%02dT%02d:%02d:%02dZ\", \"temperatureCelsius\": %g, \"humidityPercent\": %g}",
now.tm_year + 1900, now.tm_mon + 1, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec, temperature, humidity);
printf("%s\n", msg);
if (spotflow_client_send_message(client, ctx, NULL, NULL, (const uint8_t*)msg, strlen(msg)) != SPOTFLOW_OK)
{
show_last_error();
return;
}
Sleep(5000);
}
free(msg);
spotflow_message_context_destroy(ctx);
}
int main()
{
spotflow_client_options_t* options;
spotflow_client_options_create(&options, "my-device", "<Your Provisioning Token>", "spotflow.db");
spotflow_client_t* client;
if (spotflow_client_start(&client, options) != SPOTFLOW_OK)
{
show_last_error();
return 1;
}
send_data(client);
spotflow_client_destroy(client);
spotflow_client_options_destroy(options);
}
Replace the placeholder <Your Provisioning Token>
with your Provisioning Token and run the program:
- Linux
- Windows
Make sure that you have gcc
and make
installed.
Navigate to the directory examples/gcc_makefile_dynamic
and run the following command:
make run
Open the solution examples/vs2022_dynamic/spotflow_example.sln
in Visual Studio 2022.
Press F5 or Debug > Start Debugging to build and run the example program.
spotflow_client_start
will display the following text:
Provisioning operation initialized, waiting for approval.
Operation ID: b170c9ab-961c-4c02-af88-d4287d9cea1f
Verification Code: jgcjtprw
After you approve the operation in the next step, the Device will start sending the data as short Messages.
4.2. Approve Device
While the code on the Device side is still running, you'll now approve the Provisioning Operation started in the previous step:
- Portal
- CLI
- API
Expand the link Devices in the left sidebar if it's not already expanded. Open the link Approvals.
The list of Provisioning Operations opens. You should see a row with the Device ID
my-device
. Click Approve in the column Actions.The approval dialog window shows the Provisioning Operation details and allows you to override Device registration details. Leave the default values and click Approve.
Good job! The Device disappeared from the table because its state changed to Approved, while the current filter shows only the Devices in the state Waiting for Approval. When the Device SDK completes the registration, the Device changes its state to Completed and appears in the table of all registered Devices. Navigate to it by clicking the link Devices in the left sidebar.
You should see a row in the table with the Device ID
my-device
. If you don't see it, the Device hasn't completed the registration yet. Ensure that the code on the Device side finished the registration and proceeded to send Messages, and click the refresh button after a few seconds. Click the Device IDmy-device
to see the details.The Device Details page is useful to inspect the Device state. The Connection Status shows whether the Device is currently connected to the Platform. In our case, the status will be Connected when the program is sending Messages and Disconnected otherwise. Statistics show the recent traffic from the Device. There might be a lag of several seconds before the Portal shows the current information, so refresh the page as needed.
The following instructions expect that you have already installed the CLI and logged in.
Run the following command in a different terminal window than where the Device SDK is running.
Replace the placeholder <Your Provisioning Operation ID>
by the Operation ID
you received from the Device in the previous step.
spotf provisioning-operation approve --provisioning-operation-id <Your Provisioning Operation ID>
The CLI will confirm the Provisioning Operation approval:
Provisioning operation 'b170c9ab-961c-4c02-af88-d4287d9cea1f' approved successfully.
The following instructions expect that you have already obtained the API access token from the Portal and that you know the Workspace ID.
Replace the placeholders <Your Workspace ID>
, <Your API Access Token>
, and <Your Provisioning Operation ID>
with your Workspace ID, API access token, and Provisioning Operation ID and run the following command to approve the Provisioning Operation:
- cURL
- PowerShell
curl -X PUT 'https://api.eu1.spotflow.io/workspaces/<Your Workspace ID>/provisioning-operations/approve' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <Your API Access Token>' \
-d '{"provisioningOperationId": "<Your Provisioning Operation ID>"}' \
-w "%{http_code}"
(Invoke-WebRequest -Method Put -Uri 'https://api.eu1.spotflow.io/workspaces/<Your Workspace ID>/provisioning-operations/approve' `
-Headers @{
'Content-Type' = 'application/json'
'Accept' = 'application/json'
'Authorization' = 'Bearer <Your API Access Token>'
} `
-Body '{"provisioningOperationId": "<Your Provisioning Operation ID>"}').StatusCode
The API will return the code 201
to confirm the approval.
Finally, if you look at the program output, you should see that the device is registered and started sending Messages:
Provisioning operation initialized, waiting for approval.
Operation ID: b170c9ab-961c-4c02-af88-d4287d9cea1f
Verification Code: jgcjtprw
{"timestamp": "2023-10-02T13:26:34.351761+02:00", "temperatureCelsius": 21.0, "humidityPercent": 50.0}
{"timestamp": "2023-10-02T13:26:39.358295+02:00", "temperatureCelsius": 21.05, "humidityPercent": 50.1}
{"timestamp": "2023-10-02T13:26:44.370000+02:00", "temperatureCelsius": 21.1, "humidityPercent": 50.2}
...
Continue to the next section even if the program is still running.
The Device SDK documentation provides more information for both its Python and C versions.
5. View Data
We'll now show you how to visualize each received Message in real time using Grafana and how to view multiple stored Messages.
5.1. Visualize Data in Grafana
Open the link Grafana in the left sidebar.
The Home page of the integrated instance of Grafana will open in a new browser tab. It answers some common questions about how you can use it. Click the menu icon.
Open the link Explore in the menu.
In the query editor, open the data-source picker.
Select the data source that starts with
device_metric
. The other one contains the usage data of your Workspace.Click Select table.
The Platform creates a new table from each metric it receives in any Message. It also changes the name of the metric into the snake case. Select
humidity_percent
.Because we want to know when the Device took the measurement, select the
"time"
Column.Click the + button to add another column.
Choose the second column. Select
value
.Grafana shows only the last 50 records by default. To change this, click Order and erase the Limit.
Expand the options of the big Run query button in the top-right corner. Select 5s to automatically refresh the query every 5 seconds.
Scroll down to the query results. If the Device is still sending Messages, you'll see them appearing as rows in the Table and points in the Graph in real time.
If the program finished sending Messages, you can rerun it to see the data appearing in Grafana. You don't need to approve the Device this time because it's already registered.
Feel free to explore the received data and create custom dashboards, as described in the official Grafana documentation. To learn more about the integrated instance of Grafana and the format it accepts, see the User Guide. To develop custom streaming applications, look at Egress Sinks.
5.2. Inspect Stored Data
By default, all the Streams in a Workspace store the received Messages as blobs into the same Azure storage account. We'll show you how to get its shared access signature (SAS) URL that you'll later use to access the data:
- Portal
- CLI
- API
Open the link Workspaces in the left sidebar.
Click the Name of the Workspace you are currently using.
In the Workspace Details page, click Connect to storage.
Keep the default values and click Generate.
Click the copy icon to copy the generated SAS URL to the clipboard.
Supposing you have already installed the CLI and logged in, run the following command:
spotf workspace storage generate-secure-uri --container Messages --output json --query secureUri
The CLI will display the SAS URL:
https://ygemvpvpam2b9nwtt9gwmpzk.blob.core.windows.net/messages?sv=2021-12-02&se=3023-02-18T14%3A29%3A17Z&si=workspace-52aefb52-6ed8-453e-83e9-0048511f7ce9&sr=c&sig=ThqZ6N3Jjmp0e0qjq4enIUDI%2Fhh1QxxAHMm1Y2wk8Yo%3D
Copy the value to the clipboard.
The following instructions expect that you have already obtained the API access token from the Portal and that you know the Workspace ID.
Replace the placeholders <Your Workspace ID>
and <Your API Access Token>
with your Workspace ID and API access token and run the following command to get the SAS URL:
- cURL
- PowerShell
curl -X POST 'https://api.eu1.spotflow.io/workspaces/<Your Workspace ID>/storage/secure-uri' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <Your API Access Token>' \
-d '{"container": "Messages", "duration": "365:00:00:00"}'
(Invoke-WebRequest -Method Post -Uri 'https://api.eu1.spotflow.io/workspaces/<Your Workspace ID>/storage/secure-uri' `
-Headers @{
'Content-Type' = 'application/json'
'Accept' = 'application/json'
'Authorization' = 'Bearer <Your API Access Token>'
} `
-Body '{"container": "Messages", "duration": "365:00:00:00"}').Content
The API will return the SAS URL:
{
"secureUri": "https://ygemvpvpam2b9nwtt9gwmpzk.blob.core.windows.net/messages?sv=2021-12-02&se=3023-02-18T14%3A29%3A17Z&si=workspace-52aefb52-6ed8-453e-83e9-0048511f7ce9&sr=c&sig=ThqZ6N3Jjmp0e0qjq4enIUDI%2Fhh1QxxAHMm1Y2wk8Yo%3D"
}
Copy the value of the property secureUri
to the clipboard.
We'll show you how to access the Messages in Azure Blob Storage using Azure Storage Explorer and Azure CLI. Select the one that suits you best:
- Azure Storage Explorer
- Azure CLI
Go to the Azure Storage Explorer website and download the version for your operating system. Install and launch the program, then continue with the following steps:
In the left sidebar, click the connection icon.
From the available resource types in the pop-up wizard, select Blob container or directory.
Choose Shared access signature URL (SAS) as the connection method. Click Next.
Enter your SAS URL into Blob container or directory SAS URL, Display name will be then filled automatically. Click Next.
Click Connect.
After the wizard closes, the blob container appears in the hierarchy of the panel Explorer. The table with the container's contents also opens in the main area. By default, it shows the blobs in a hierarchical structure. For better orientation, we will show their full names instead. Click the filter icon on the top right of the panel.
In List Mode, select Flat.
You should now see a list of blobs (files). Close the view options by clicking the filter icon again.
Double-click one of the blobs to download it.
If a security warning about an untrusted extension appears, you can safely click Yes. Open the downloaded file in a text editor.
The file contains the content of the selected Message.
Follow the instructions in the Azure CLI documentation to install the CLI. You don't need to have an Azure subscription to use it.
The SAS URL you obtained in the previous step consists of the following parts:
https://<Your Storage Account Name>.blob.core.windows.net/<Your Container Name>?<Your SAS Token>
Extract these parts from the SAS URL and use them in the following command:
az storage blob list --account-name <Your Storage Account Name> --container-name <Your Container Name> --sas-token """<Your SAS Token>""" --query "[].name"
The Azure CLI will show the list of blobs (files) in the container:
[
"default/default/my-device/2023-10-02-11-26/00000000010000000000000007287",
"default/default/my-device/2023-10-02-11-26/00000000010000000000000007288",
"default/default/my-device/2023-10-02-11-26/00000000010000000000000007289",
...
]
Select the name of one of these blobs and use it in the following command to download the blob as the file message.txt
.
:
az storage blob download --account-name <Your Storage Account Name> --container-name <Your Container Name> --name <Your Blob Name> --file "message.txt" --sas-token """<Your SAS Token>"""
The downloaded file message.txt
will contain the content of the selected Message:
{"timestamp": "2023-10-02T13:26:34.351761+02:00", "temperatureCelsius": 21.0, "humidityPercent": 50.0}
Learn more about how the Platform stores the received data in the User Guide.
You can find more information about Azure Blob Storage in the official documentation. Apart from Azure Storage Explorer and Azure CLI, you can also use Azure SDKs available in multiple programming languages, or call the REST API directly.
Summary
Congratulations on getting this far! If you followed the previous steps, your Device can now send telemetry to the Spotflow IoT Platform, the Platform stores all the received data in Azure Blob Storage, and you can see the measurements arriving in real time using Grafana. Let's review how you and your Device interacted with the Platform:
- You created a Workspace, which serves as a container for all the assets in the Platform.
- You configured the Stream
default-stream
(located in the Stream Groupdefault-stream-group
) to immediately forward the received Messages to the integrated instance of Grafana. - You created a Provisioning Token and stored it in your Device.
- The Device used the Provisioning Token to create an instance of Provisioning Operation.
- While the Device was waiting, you approved the operation.
- The Device finished the operation and obtained credentials for connecting to the Platform.
- The Device started sending Messages to the Stream
default-stream
- The Platform forwarded all the received Messages to the integrated instance of Grafana so you could see them in real time.
- Simultaneously, the Platform saved each Message as a separate blob in Azure Blob Storage.
- You created a custom query in Grafana to display the received data.
- You connected to Azure Blob Storage, inspected the Messages, and downloaded one of them.
Any other Device can now use the Provisioning Token and send its Messages to the Stream default-stream
.
Hundreds or thousands of Devices write to the same Stream in real-life scenarios.
What's Next
- We provide the reference of the Device SDK both for Python and C.
- To control the Platform without using the Portal, see the references of CLI and API.
- If you have any questions or requests, contact us.