In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This case is suitable for developers to get started understanding several products such as Azure Functions/ IoT Hub / Service Bus / Power BI.
The main contents of actual combat are as follows:
Upload equipment telemetry data to the Internet of things center
Routing telemetry data to the Topic of message middleware
Use Azure Function to parse the message in the message middleware Topic and push it to the big screen.
Let's take a look at the basic concepts of Azure Functions:
Https://v.qq.com/x/page/j3031z2zlns.html
Create a Functions in Azure Portal and experience:
Https://v.qq.com/x/page/v3031m1g9vv.html
For the preparation of IoT Hub and Service Bus, please refer to:
The device data is pushed to the Power BI data screen by Azure Functions to display (1. Preparatory work)
Create and publish a Functions using Visual studio 2019:
Https://v.qq.com/x/page/a3031iu2d4q.html
The sample code in this example:
Using System;using System.IO;using System.Net;using System.Text;using Microsoft.Azure.WebJobs;using Microsoft.Azure.WebJobs.Host;using Microsoft.Extensions.Logging;using Newtonsoft.Json Namespace FunctionApp2 {public static class Function1 {[FunctionName ("Function1")] public static void Run ([ServiceBusTrigger ("fromiothubtopic", "sub", Connection = "sbconn")] string mySbMsg, ILogger log) {log.LogInformation ($"C# ServiceBus topic trigger function processed message: {mySbMsg}"); string url = "https://api.powerbi.cn/beta/ Please replace with your own URL" IoTDeviceMsg msg = JsonConvert.DeserializeObject (mySbMsg); / / Create JSON message var telemetryDataPoint = new {temperature = msg.temperature, humidity = msg.humidity, time = DateTime.Now}; var messageString = JsonConvert.SerializeObject (telemetryDataPoint); HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url) Req.Method = "POST"; req.Timeout = 8000 ram / set request timeout in milliseconds req.ContentType = "application/json"; byte [] data = Encoding.UTF8.GetBytes ("[" + messageString + "]"); req.ContentLength = data.Length Using (Stream reqStream = req.GetRequestStream ()) {reqStream.Write (data, 0, data.Length); reqStream.Close ();} HttpWebResponse resp = (HttpWebResponse) req.GetResponse (); Stream stream = resp.GetResponseStream () / / get the response content if (resp.StatusCode = = HttpStatusCode.OK) {log.LogInformation ($"OK: {messageString}");}} public class IoTDeviceMsg {public decimal temperature {get; set;} public decimal humidity {get; set;}
For developers getting started, you need to pay attention to the following basic concepts:
1.Azure Functions Trigger
AzureFunctions provides several templates, which support the following triggers:
HTTPTrigger-use a HTTP request to trigger code execution.
TimerTrigger-performs cleanup or other batch tasks according to a predefined schedule.
CosmosDBTrigger-Azure CosmosDB documents are processed when they are added or updated as collections in the NoSQL database.
QueueTrigger-responds to messages when they reach the Azure storage queue.
The BlobTrigger-Azure stores the blob when the blob is added to the container. You can use this function to resize images.
EventHubTrigger-responds to events passed to the Azure event center.
ServiceBusQueueTrigger-connects code to other Azure services or local services by listening on message queues.
ServiceBusTopicTrigger-connects code to other Azure services or local services by subscribing to topics.
2. Azure Functions integration
AzureFunctions can integrate with a variety of Azure and third-party services. These services can trigger the function to start execution, or they can be used as input and output to the code. AzureFunctions supports the following service integration:
Azure CosmosDB
Azure event Center
Azure Notification Center
Azure service bus (queues and topics)
Azure storage (blob, queues, and tables)
Local (using service bus)
There are two billing methods:
Usage Plan (Consumptionplan): pay only for code run time
Application Service Plan (App Serviceplan): runs the function like a Web application. If you have used application services for other applications, you can run your own functions on the same schedule without paying extra.
For specific billing, please refer to:
Https://www.azure.cn/zh-cn/pricing/details/azure-functions/
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.