none
Sample code to access Gen2 REST api

    Question

  • Hi,

    for the Gen2 api, we have the following link describing the operations.

    https://docs.microsoft.com/en-us/rest/api/storageservices/data-lake-storage-gen2

    But it does not include examples of how to make each call.

    Do any examples exist yet? (C# code, etc.)

    If so can you please share the links?

    Thanks


    Monday, March 4, 2019 12:08 AM

All replies

  • Hi there,

    These are the Rest APIs for the data lake storage gen2 operations. REST APIs can be invoked anywhere and in any way based on your use case. For example - To invoke REST APIs from C#, please follow this :

    https://docs.microsoft.com/en-us/aspnet/web-api/overview/advanced/calling-a-web-api-from-a-net-client

    You can basically invoke these REST APIs and parse and use the responses in your client code to tailor to your use case.

    Hope this helps.


    MSDN

    Monday, March 4, 2019 9:39 AM
    Moderator
  • ok I understand what you are saying that it is just like any other REST api.

    But if you see similar documents for the previous versions (Blob REST api, etc.), you can see that there is actual sample code provided in the same documents, and even other pages related to it - like the following

    https://docs.microsoft.com/en-us/rest/api/storageservices/list-containers2

    at the bottom of this page you can see "sample code".

    So that is what I was asking about whether something like this exists yet for Gen2.

    thanks

    Monday, March 4, 2019 1:45 PM
  • Hi there,

    Sorry for the delayed response. I got in touch with the Team and got some examples for you :

    Create a file system

    curl -i -X PUT -H "x-ms-version: 2018-11-09" -H "content-length: 0" -H "Authorization: Bearer $ACCESS_TOKEN" "https://$STORAGE_ACCOUNT_NAME.dfs.core.windows.net/mydata?resource=filesystem"



    Once complete, the server returns a 201 Created response.

    Create a directory

    To create a directory in the file system, use the following command:

    curl -i -X PUT -H "x-ms-version: 2018-11-09" -H "content-length: 0" -H "Authorization: Bearer $ACCESS_TOKEN" "https://$STORAGE_ACCOUNT_NAME.dfs.core.windows.net/mydata/data?resource=directory"

    Create a file

    Next, issue some PUT commands to the server to create a few files. Make sure to create both files as each are used in subsequent examples.

    curl -i -X PUT -H "x-ms-version: 2018-11-09" -H "content-length: 0" -H "Authorization: Bearer $ACCESS_TOKEN" "https://$STORAGE_ACCOUNT_NAME.dfs.core.windows.net/mydata/data/file1?resource=file"curl -i -X PUT -H "x-ms-version: 2018-11-09" -H "content-length: 0" -H "Authorization: Bearer $ACCESS_TOKEN""https://$STORAGE_ACCOUNT_NAME.dfs.core.windows.net/mydata/data/file2?resource=file"


    Once complete, the server returns a 201 Created response for each command.

    Hope this helps!


    MSDN

    Wednesday, March 20, 2019 10:44 AM
    Moderator
  • Hello,

    I can not send content to a file from rest api
    Do you have a sample code to use the PUT RANGE method ?

    Thanks

    Tuesday, April 23, 2019 2:32 PM
  • Hi BBHekD,

    Do you want to write to a file on ADLS Gen2 using the REST APIs? If yes, please refer to this thread for a step by step guide for the same.


    MSDN

    Monday, April 29, 2019 9:51 AM
    Moderator