Free cookie consent management tool by TermsFeed Policy Generator

How to save JSON to Azure SQL Database in Azure Data Factory

Apresentamos nesse vídeo como copiar parte do resultado em formato JSON para salvar no banco de dados SQL do Azure utilizando o Azure Data Factory.

We'll get to know the techniques:

1. Postman tool and the POSTMAN API PLATFORM:

  • Postman is a collaborative tool for API development. The following is a basic example of how to use Postman to access

    the YouTube Data API:
    • Create a GET request to the YouTube API URL, for example:GET

      https://www.googleapis.com/youtube/v3/videos
      
    • Add the necessary parameters, such as API key, to authenticate your request.

    • Execute the request and view the response in JSON format.

2. JSON Format, HTTP Response:

  • When making an HTTP request to an API, the response is usually in JSON format. JSON Response Example:

    {
      "name": "Example",
      "age": 30,
      "city": "Exemplopolis"
    }
    

3. Get data from the internet (WEB ACTIVITY):

  • In Azure Data Factory, the "Web" activity can be used to get data from the internet. Example

    :"
    activities": [
      {
        "name": "WebActivitySample",
        "type": "Web",
        "linkedServiceName": {
          "referenceName": "YourLinkedServiceName",
          "type": "LinkedServiceReference"
        },
        "userProperties": [
          {
            "name": "Url",
            "value": "https://api.example.com/data"
          }
        ]
      }
    ]
    

4. Create and set variable (VARIABLES: IN

  • Azure Data Factory, you can create and define variables using the "Set Variable" activity. Example

    :"
    activities": [
      {
        "name": "SetVariableActivity",
        "type": "SetVariable",
        "linkedServiceName": {
          "referenceName": "YourLinkedServiceName",
          "type": "LinkedServiceReference"
        },
        "typeProperties": {
          "variableName": "YourVariableName",
          "value": "ExampleValue"
        }
      }
    ]
    

5. Insert record into Azure SQL Database table (SCRIPT ACTIVITY, CREATE TABLE, INSERT, SQL CODES):

  • Use the "Script" activity to run SQL scripts in Azure Data Factory. Example

    :"
    activities": [
      {
        "name": "SqlScriptActivity",
        "type": "SqlScript",
        "linkedServiceName": {
          "referenceName": "YourLinkedServiceName",
          "type": "LinkedServiceReference"
        },
        "typeProperties": {
          "script": "CREATE TABLE ExampleTable (ID INT, Name VARCHAR(255));
    INSERT INTO ExampleTable VALUES (1, 'John'); "
        }
      }
    ]
    

6. Query table with

data in JSON format (SELECT, CROSS APPLY, JSON_VALUE):
  • To query a SQL table in Azure Data Factory and get data in JSON format, use the "Lookup" or "Copy" activity. Example query:

    SELECT ID, Name FROM ExampleTable FOR JSON AUTO
    

These are basic examples, and the details may vary depending on your specific environment and Azure Data Factory requirements.

This content contains
  • Content Video
  • Language Portuguese
  • Duration 16m 56s
  • Subtitles Sim

  • Reading time 2 min 1 seg

avatar
Fabio Santos

Data Scientist and Consultant for Digital and Analytics Solutions


  • Share

Youtube Channel

@fabioms

Subscribe now