locked
API to Azure SQL Database RRS feed

  • Question

  • User-1256377279 posted

    Hi All,

    Is there a way can we straight insert API json data into Azure SQL Database also is it possible to do scheduling ?

    Thanks,

    Shabbir

    Tuesday, June 16, 2020 5:32 PM

All replies

  • User-474980206 posted

    Sure, azure sql, just like Sqlserver stores json in a text column. You use the azure scheduler for scheduled events

       https://docs.microsoft.com/en-us/azure/scheduler/scheduler-intro

    Tuesday, June 16, 2020 11:26 PM
  • User-1256377279 posted
    Thanks can you give an example to use Azure sql to call API and deserialise Json and store into sql table.

    Many thanks
    Shabbir
    Wednesday, June 17, 2020 3:58 AM
  • User-474980206 posted
    var data = new {
        message = "hello"
    };
    
    using (var conn = new SqlConnection(connectionString))
    {
       using (var cmd = conn.CreateCommand())
       {
           conn.Open();
           cmd.CommandText = "INSERT MyTable (JsonData) Values (@data)";
           cmd.Parameters.AddWithValue("@data", JsonConvert.SerializeObject(data));
           cmd.ExecuteNonQuery();
       }
    }

    Wednesday, June 17, 2020 3:37 PM