How to connect T-mobile to AzureHUB?
-
I am using an MKRNB1500 with an IoT T-mobile SIM card and I am able to send data to the T-Mobile page.
I would like to connect the T-mobile with the AzureHUB. How can I do that?I followed the steps and created a FunctionApp, but when I copy and paste that long program in C# that is suggested from the website guide and run it…it creates an error message.
PROGRAMME
#r “Microsoft.WindowsAzure.Storage”using System;
using System.Configuration;
using System.Net;
using System.Text;
using Microsoft.Azure;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
HttpStatusCode result;
string contentType;result = HttpStatusCode.OK; contentType = req.Content.Headers?.ContentType?.MediaType; if(contentType == "application/json") { string body; body = await req.Content.ReadAsStringAsync(); if(!string.IsNullOrEmpty(body)) { string name; name = Guid.NewGuid().ToString("n"); await CreateBlob(name + ".json", body, log); result = HttpStatusCode.OK; } } return req.CreateResponse(result, string.Empty);
}
private async static Task CreateBlob(string name, string data, TraceWriter log)
{
string accessKey;
string accountName;
string connectionString;
CloudStorageAccount storageAccount;
CloudBlobClient client;
CloudBlobContainer container;
CloudBlockBlob blob;accessKey = ConfigurationManager.AppSettings["StorageAccessKey"]; accountName = ConfigurationManager.AppSettings["StorageAccountName"]; connectionString = "DefaultEndpointsProtocol=https;AccountName=" + accountName + ";AccountKey=" + accessKey + ";EndpointSuffix=core.windows.net"; storageAccount = CloudStorageAccount.Parse(connectionString); client = storageAccount.CreateCloudBlobClient(); container = client.GetContainerReference("nbiot"); await container.CreateIfNotExistsAsync(); blob = container.GetBlockBlobReference(name); blob.Properties.ContentType = "application/json"; using (Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(data))) { await blob.UploadFromStreamAsync(stream); }
}
ERROR MESSAGE:
2019-05-11T14:30:44 Welcome, you are now connected to log-streaming service.
2019-05-11T14:30:55.912 [Information] Executing ‘Functions.TmobileIoT’ (Reason=‘This function was programmatically called via the host APIs.’, Id=b2acae17-00ad-4d4b-9676-4d08d14c5e89)
2019-05-11T14:30:55.979 [Error] Function compilation error
Microsoft.CodeAnalysis.Scripting.CompilationErrorException : Script compilation failed.
at async Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.CreateFunctionTarget(CancellationToken cancellationToken) at C:\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\DotNetFunctionInvoker.cs : 314
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.Description.FunctionLoader`1.GetFunctionTargetAsync[T](Int32 attemptCount) at C:\azure-webjobs-sdk-script\src\WebJobs.Script\Description\FunctionLoader.cs : 55
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.GetFunctionTargetAsync(Boolean isInvocation) at C:\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\DotNetFunctionInvoker.cs : 183
2019-05-11T14:30:56.100 [Warning] run.csx(11,75): warning CS0618: ‘TraceWriter’ is obsolete: ‘Will be removed in an upcoming version. Use Microsoft.Extensions.Logging.ILogger instead.’
2019-05-11T14:30:56.101 [Warning] run.csx(41,64): warning CS0618: ‘TraceWriter’ is obsolete: ‘Will be removed in an upcoming version. Use Microsoft.Extensions.Logging.ILogger instead.’
2019-05-11T14:30:56.137 [Error] run.csx(38,16): error CS1501: No overload for method ‘CreateResponse’ takes 2 arguments
2019-05-11T14:30:56.207 [Error] Executed ‘Functions.TmobileIoT’ (Failed, Id=b2acae17-00ad-4d4b-9676-4d08d14c5e89)
Script compilation failed.Also I do not really grasp the concept of sending regularly data from a sensor, since AT commands works if you type them and not automatically. Serial.printing them doesn’t work in the serial monitor of the arduino ide. Could you also help for this problem? If not it is also ok.
-
2019-05-11T14:30:56.137 [Error] run.csx(38,16): error CS1501: No overload for method ‘CreateResponse’ takes 2 arguments
2019-05-11T14:30:56.207 [Error] Executed ‘Functions.TmobileIoT’ (Failed, Id=b2acae17-00ad-4d4b-9676-4d08d14c5e89)
Script compilation failed.Please look at this error, seems you made a mistake in your code.
Also I do not really grasp the concept of sending regularly data from a sensor, since AT commands works if you type them and not automatically. Serial.printing them doesn’t work in the serial monitor of the arduino ide. Could you also help for this problem? If not it is also ok.
You have to write code that sends AT commands to the modem on a regular basis. You can use the Arduino IDE for that.
-
@stefan-de-lange Yeah, sorry your answer is not really helping.
I already know that there is an error in the code and that I have to write a ‘code’ to send data automatically with the ArduinoIDE.The T-mobile instructions are not enough for someone to be able to connect from the T-mobile Cloud to the MicrosoftAzure. They omit a lot of things and they assume that people knows already how to connect them.
-
@alessandro-mirabella OK, then you have to provide more information otherwise I can not help you.
-
@stefan-de-lange I have a temperature and moisture sensor with an MKRNB1500.
I want to send data without inputing an at-commands, therefore sending data continuously to the t-mobile network, then from the t-mobile network to the IOTHUB in MicrosoftAzure.With SigFox it is very easy to do it, but with NBIoT technology I find it very difficult.
Is there an example Arduino Program that shows how to send data automatically?
Is there a tutorial that shows you how to connect the T-mobile Callback URL to the IOTHUB in Azure?![alt text]( image url)
-
@stefan-de-lange If you need more information, please let me know.
I am using the library MKRNB --> SerialSARAPassthrough -
Hello Alessando.
Do you have already connected your device with Azure? We are working here with a bridge between T-Mobile and Azure so we can send the data to an IOT-HUB.
Greetings Gerrit