Help wanted - how to read data from webservice and write it to Azure SQL

Welcome Forums General PowerShell Q&A Help wanted - how to read data from webservice and write it to Azure SQL

This topic contains 3 replies, has 3 voices, and was last updated by

2 years, 1 month ago.

  • Author
  • #60909

    Points: 0
    Rank: Member


    I have access to a Point of Sales web service from where I can read sales from the registers. I would like to create an automated task in Azure with a PS script that once a day could read the sales and import the numbers to a SQL Azure database.

    The source string looks like this (username and password changed):

    The timestamps needs to be automatically calculated and in EPOCH format when reading data e.g. the last 24 hours each time the runbook run.

    When data is read they will have to be imported in to an existing SQL database in a specific view hosted in Azure.

    I am a novice into PowerShell but have been told it can do the trick.

    Any help will be highly appreciated.

    Thanks in advance,

    Kind regards

  • #60952

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    Well... what, specifically, do you need help with? Right now you have a pretty high level problem statement, but short of just writing a script for you, I'm not sure what to help with.

  • #60970

    Points: 24
    Team Member
    Rank: Member

    Here is a short snippet on how to create the "from" and "to" timestamps in EPOCH format (Unix timestamp).

    $now = [DateTime]::UtcNow
    $epochBase = [DateTime]'1970-01-01 00:00:00'
    $fromEpoch = [UInt32]($now.AddHours(-24) - $epochBase).TotalSeconds
    $toEpoch = [UInt32]($now - $epochBase).TotalSeconds

    To invoke tha actual request reading data from the web service I would attempt to use the PowerShell cmdlet Invoke-RestMethod cmdlet. As alternative Invoke-WebRequest if the API doesn't return a JSON document.

    1. Check out the examples of the Invoke-RestMethod and Invoke-WebRequest documentation pages:

    2. Use your Bing/Google fue to look for examples related to Invoke-RestMethod.

    3. Have a look at the code of this PowerShell module for the OpenWeather API from a fellow PowerSheller:

    I hope above is helpful to get you going further. Please let us know any further questions. If you code already, please feel free to post it in "pre" tags or reference a GitHub Gist.

  • #60987

    Points: 0
    Rank: Member

    Hi Daniel,

    Thank you for your help. I must admit this will be too complicated for me and I will need some assistance for making the script right. I think I will go ahead and find a freelance consultant who can assist me on this one.

    Thanks again and a happy new year 🙂

    Kind regards

The topic ‘Help wanted - how to read data from webservice and write it to Azure SQL’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort