There shouldn't be a problem inserting content with 0 length.
A simple way to use ADLS Gen2 APIs (Using OAuth2) to create a file would be :
- Acquire an Access token by making a POST request to https://login.microsoftonline.com/\<tenant id>/oauth2/v2.0/token Headers : "Content-Type: application/x-www-form-urlencoded" Body : {"client_id": <CLIENT_ID>, "client_secret": <CLIENT_SECRET>, "scope" : "https://storage.azure.com/.default", "grant_type" : "client_credentials" }
- Create a file system by making a PUT request to https://<storage account name>.dfs.core.windows.net/<file system name>?resource=filesystem Headers : Content-Length : 0 "x-ms-version":"2018-11-09" Authorization : Bearer <access_token from step1>
- Set default permissions on the root directory by making a PATCH request to https://<storage account name>.dfs.core.windows.net/<file system name>?action=setAccessControl Headers : Content-Length : 0 "x-ms-version":"2018-11-09" Authorization : Bearer <access_token from step1> x-ms-acl :
user::rwx,group::r-x,other::--x,default:user::rwx,default:group::r-x,default:other::-- - Create a directory by making a PUT request to https://<storage account name>.dfs.core.windows.net/<file system name>/<directory name>?resource=directory Headers : Content-Length : 0 "x-ms-version":"2018-11-09" Authorization : Bearer <access_token from step1>
- Create a file by making a PUT request tohttps://<storage account name>.dfs.core.windows.net/<file system name>/<directory name>/<file
name>?resource=file Headers : Content-Length : 0 "x-ms-version":"2018-11-09" Authorization : Bearer <access_token from step1>
For more details, please refer this MSDN thread.
Hope this helps.