I am trying to learn the Azure IoT hub, but I am unable to send data to my IoT hub using Postman.
I did the following:
Create Azure IoT hub
Create a device using Azure Portal CLI
Copied the text where it said "primary key" on the Device page
My request looks as follows:
POST https://myhub.azure-devices.net/devices/MyDevice/messages/events?api-version=2020-03-13
I have added the authorization header, which has the value:
SharedAccessSignature=SharedAccessSignature sr=myhub.azure-devices.net%2Fdevices%2FMyDevice&sig=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Where the key is the copied text from the "primary key" field from the device page.
Content-type is set to application/json. But the body is currently empty.
I am getting the following response:
"Message": "ErrorCode:ServerError;InternalServerError",
Note: Hub and device name are not the same as stated here.
For a quick-start on this, we have 3 stages 1) SAS key generation from Visual Studio Code see below images(Or from CLI please see the answer posted by silent) 2) Use Postman 3) Monitor via VS code
Steps: VS Code
1) Install VS Code extension tools for Azure IoT & Connect your IoT Hub as per onscreen instructions
2) You can see the list of devices in VS code Explorer. Now right click the device (created in the portal) and select 'Generate SAS Token for the device', give the time in hours like 24 and hit enter.Copy the SAS key from output window fully (entire). Sample shown below.
SharedAccessSignature
sr=deviothub.azure-devices.net%2Fdevices%2FNewDevice&sig=H3II%2FCa5Km5V2pieP5Ti1SI%3D&se=1590867649
Steps Postman
1) I hope you have already visited this document on Azure IoT Hub REST API
Replace the required sections with your IoT Hub values.
POST
https://fully-qualified-iothubname.azure-devices.net/devices/{id}/messages/events?api-version=2020-03-13
2) Make sure to include the fully copied SAS token and use it in the header section of POST call
3) Body content : It depends on your use case.
example 'raw'--JSON--> {"Temperature":54}
**You can see the accepted response from IoT Hub as '204 No Content'
Step Monitor the Telemetry the easy way
1) Open the VS Code editor and right click the particular device and slect 'Start Monitoring the in built events'
2) Send another telemetry from Postman and you can see the message arrived at IoT Hub and is visible on the VS code Monitoring screen.
Happy Azure IoT Learning
You need to calculate the auth header based on your primary key, not just put it into the header. See here for examples how to do this, for instance by using CLI az iot hub generate-sas-token
Related
Can I use the Azure Speech resource without an endpoint?
I was working through the microsoft tutorials. Specifically, I was completing this lab. And in this lab the application client of the Speech resource does not use the endpoint, it only uses the key and location.
The same is told here in the documentation:
To find the keys and location/region of a completed deployment, follow these steps:
1. Sign in to the Azure portal using your Microsoft account.
2. Select All resources, and select the name of your Cognitive Services resource.
3. On the left pane, under RESOURCE MANAGEMENT, select Keys and Endpoint.
Each subscription has two keys; you can use either key in your application. To copy/paste a key to your code editor or other location, select the copy button next to each key, switch windows to paste the clipboard contents to the desired location.
Additionally, copy the LOCATION value, which is your region ID (ex. westus, westeurope) for SDK calls.
As you can see there is nothing told about the endpoint. Meaning that somehow the Speech resource client will know how to connect to the Speech resource by having just the key and location.
I am really confused, because I thought it should be impossible to do without an endpoint.
E.g. here the code samples which use the Speech resource do not use any endpoints (only a key and a location):
import os
from playsound import playsound
from azure.cognitiveservices.speech import SpeechConfig, SpeechRecognizer, AudioConfig
# Get spoken command from audio file
file_name = 'light-on.wav'
audio_file = os.path.join('data', 'speech', file_name)
# Configure speech recognizer
speech_config = SpeechConfig(cog_key, cog_location)
audio_config = AudioConfig(filename=audio_file) # Use file instead of default (microphone)
speech_recognizer = SpeechRecognizer(speech_config, audio_config)
# Use a one-time, synchronous call to transcribe the speech
speech = speech_recognizer.recognize_once()
# Play the original audio file
playsound(audio_file)
# Show transcribed text from audio file
print(speech.text)
I mean I can not even imagine how the Speech resource client (implemented by Microsoft) knows that it should connect to the resource in my Azure portal and not in some other portal without the endpoint. Looks like a magic to me, so I am definitely missing something here.
Thank you for trying Azure Speech service.
You're absolutely right - Speech service does use endpoints like any other cloud service of this kind.
If your code is using Speech SDK, then SDK provides the right endpoint for you, based upon the information you have provided, namely location.
I see from your code, that you are trying On-line transcription. Here you will find all regional endpoints used in this scenario.
There are other endpoints, like for Speech-to-text REST API V3 or Text-to-speech. They are all described in the documentation.
I'm trying to complete the tutorial of Azure Stream Analytics that using an app provided by Microsoft docs to send data to Azure Event Hub, to be simple, I'm just following this tutorial.
Now I got stuck at the step: "Start the event generator application"
What I have done is:
Create the Azure Event Hub & Azure Event Hub Namespace
Create the policy at "Shared access policies" (as below)
Update the element in the config file (telcodatagen.exe.config, as below)
The below file can be download here.
Here are the values I filled in at the shelter in the previous image:
<add key="EventHubName" value="***My Event Hubs Namespace***"/>
<add key="Microsoft.ServiceBus.ConnectionString" value="***My Connection string–primary key without the EntityPath value***"/>
But when I run the below command at CMD:
telcodatagen.exe 1000 0.2 2
I got an error as the figure below (error on send: one or more error occurred):
I'm completely brand new to Azure Event Hub and Azure Stream Analytics and I can guarantee to follow the steps of the tutorial, but I am not sure what the error is, why this error occurs and how to debug.
Any solution? Thanks!
Your ConnectionString is wrong.
You should get it from namespace,not Instance.
And EventHubName is your Event Hubs Instance's name.
By the way,you can download c# code from Github.
Hope this can help you:).
Two things to fix:
This needs to be set to the entity name not "Event Hubs Namespace".
<add key="EventHubName" value="***My Event Hubs Namespace***"/>
Remove trailing ; at the end if there is one.
<add key="Microsoft.ServiceBus.ConnectionString" value="***My Connection string–primary key without the EntityPath value***"/>
I had similar issues & downloaded the source as per Steve's comment.
I couldn't build as it targeted .Net 4.5.1
Gave up, used this blog post to build my own Event Sender
Another alternative might be try downloading .Net 4.5.1 Developer Pack & debug?
I'm traying to daploy an instance of the form recognizer app in Azure. For that I'm following the instructions in the documentation: https://learn.microsoft.com/en-us/azure/cognitive-services/form-recognizer/deploy-label-tool
I have created the docker instance and the connection, but the step to create the APP is failing.
This are the parameters I'm using:
Display Name: Test-form
Source Connection: <previuosly created connection>
Folder Path: None
Form Recognizer Service Uri: https://XXX-test.cognitiveservices.azure.com/
API Key: XXXXX
Description: None
And this is the error and getting:
I had the same error. It turned out to be due to incorrect SAS URI formatting because I generated and copied the SAS token via the Storage Accounts interface. It's much easier to get the correct format for the SAS URI if you generate it through the Storage Explorer (currently in Preview) as opposed to through the Storage Accounts.
If you read the documentation carefully it gives you a step by step guide
"To retrieve the SAS URL, open the Microsoft Azure Storage Explorer, right-click your container, and select Get shared access signature. Set the expiry time to some time after you'll have used the service. Make sure the Read, Write, Delete, and List permissions are checked, and click Create. Then copy the value in the URL section. It should have the form: https://.blob.core.windows.net/?"
Form Recognizer Documentation
The error messages point to a configuration issue with the AzureBlobStorageTemplate Thing. Most likely the containerName field for the Blob Storage Thing is empty or contains invalid characters
Ensure the containerName is a valid Azure storage container name.
Check https://learn.microsoft.com/en-us/rest/api/storageservices/Naming-and-Referencing-Containers--Blobs--and-Metadata for more information.
A container name must be a valid DNS name
The Connector loads and caches all configuration settings during startup. Any changes that you make to the configuration when troubleshooting are ignored until the Connector is restarted.
When creating the container connection, you must add the container into the SAS URI, such as
https://<storage-account>.blob.core.windows.net/<Enter-My-Container-Here>?<SAS Key>
You can also directly use the open source labeling tool, please see the section further down in the doc:
The OCR Form Labeling Tool is also available as an open-source project on GitHub. The tool is a web application built using React + Redux, and is written in TypeScript. To learn more or contribute, see OCR Form Labeling Tool.
I am trying to set up Translator with my MXChip but after I finish the deployment it says "No IOT Hub".
I believe this is because of I can not successfully complete "Config IoT Hub Connection String" step. Details of step in this tutorial
What I do in this step is
I open devkit-traslater\run.csx and fill (string subscriptionKey = "";
string deviceName = "";) with name and key1 of Translator I get from portal.azure.com
Then after this step I switch iot Kit into configuration mode.
Then I follow the steps Config Device Settings but I never receive "The configuration success notification popup bottom right corner once it's done."
I dont know what I am doing wrong here
When I follow these steps:
create event hub in a namespace with a resource group named tést (or other name with é in it)
Try to open up the event hub in the portal
Then the portal never finishes loading the event hub and I get this:
rainy cloud
I can reproduce this bug on different Azure subscriptions...
#SQLWaldorf,
I checked on this issue, when using the accent in Portal, it doesn't allow me to create the namespace since the character doesn't seem to be supported, I attached both screenshots from my experiment:
Then without accent: