简体   繁体   English

来自Azure中REST API的数据

[英]Data From REST API In Azure

I have implemented REST API calls using a standalone c# console application. 我已经使用独立的c#控制台应用程序实现了REST API调用。 The API returns JSON which i'm deserializing and then storing it in the database. 该API返回我要反序列化的JSON,然后将其存储在数据库中。 Now i want to implement the entire logic in Azure platform so that it can invoked by passing start date and an end date and store location (it should run for three location) Below is the code: 现在,我想在Azure平台中实现整个逻辑,以便可以通过传递开始日期,结束日期和存储位置(应该在三个位置运行)来调用它。下面是代码:

static void Main()
    {


        MakeInventoryRequest();

    }

    static async void MakeInventoryRequest()
    {
        using (var client = new HttpClient())
        {
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            // Request headers
            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "5051fx6yyy124hhfyuscf34f57ce9");


            // Request parameters

            queryString["query.locationNumbers"] = "4638";
            queryString["availableFromDate"] = "2019-01-01";
            queryString["availableToDate"] = "2019-03-07";


            var uri = "https://api-test.location.cloud/api/v1/inventory?" + queryString;

            using (var request = new HttpRequestMessage(HttpMethod.Get, uri))
            using (var response = await client.SendAsync(request))
            {

                var stream = await response.Content.ReadAsStreamAsync();

                if (response.IsSuccessStatusCode == true)
                {
                    List<Inventory> l1 = DeserializeJsonFromStream<List<Inventory>>(stream);

                    InsertInventoryRecords(l1);
                }


                if (response.IsSuccessStatusCode == false)
                {
                    throw new Exception("Error Response Code: " + response.StatusCode.ToString() + "Content is: " + response.Content.ReadAsStringAsync().Result.ToString());
                }
            }
        }
    }

Please suggest the best possible design using Azure components 请提出使用Azure组件的最佳设计建议

With the information in hand I think you have multiple options , you need to find out which works for you the best . 掌握了这些信息后,我认为您有多种选择,您需要找出最适合您的方法。 You can use Cloud service to host the console app ( you will have to change it to worker role , Visual studio will help you to convert that ) . 您可以使用Cloud服务托管控制台应用程序(您必须将其更改为辅助角色,Visual Studio将帮助您进行转换)。 I am not sure about the load which you are expecting but you can always increase and decrease the instance and these can be deployed to different geographies . 我不确定您所期望的负载,但是您始终可以增加和减少实例,并且可以将它们部署到不同的地理位置。

I see that you are persisting the data , if you want to do that you can use many of the SQL offerings . 我看到您正在保留数据,如果要这样做,则可以使用许多SQL产品。 For invoking the REST API you can also azure functions and ADF. 对于调用REST API,您还可以对函数和ADF进行处理。

Please feel free to comment if you want any more details on the same. 如果您想要更多有关此内容的详细信息,请随时发表评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Azure从Rest API提取数据 - Data ingestion from Rest API using Azure 如何使用 REST ZDB974238714CA8DE634A7CE1DF08 从 azure 获取 azure 指标数据 - How to get azure metrics data from azure using REST API 使用 Azure 数据工厂从 REST API 引入传入数据 - Using Azure Data Factory to ingest incoming data from a REST API 使用 Azure 数据工厂从 REST API 获取数据 - Using Azure Data Factory to get data from a REST API 使用 Azure 数据工厂从 REST API 获取数据 - GET data from REST API using Azure Data Factory 使用 Rest api 从带有防火墙的数据库请求来自 Azure 函数的数据 - Requesting data from Azure Functions with Rest api from database with firewall 使用 Azure REST API 或 Azure 数据工厂从 Azure 时间序列洞察中导出数据 - Export data from Azure Timeseries insights using Azure REST API's or Azure Data Factory 从 Rest API 到 Azure 事件中心不断地摄取数据 - Ingest data from Rest API to Azure Event Hub Constantly 使用 Azure 数据工厂从 REST API 读取 JSON - Read JSON from rest API as is with Azure Data Factory Azure 监控工作簿查询 - 从 Azure REST API Synapse 数据平面检索数据 - Azure Monitor Workbook Query - retrieve data from Azure REST API Synapse Data Plane
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM