I am trying to create an Azure function that writes to Azure Data Lake Store. I am using Managed Service Identity to, well, manage the authentication stuff.
I have enabled MSI on the Function app. I have also enabled the Function app to access the required Data Lake Store. And I am using the following code to get a token and write to ADL. AM I missing something?
var azureServiceTokenProvider = new AzureServiceTokenProvider();
string accessToken = await azureServiceTokenProvider.GetAccessTokenAsync("https://datalake.azure.net");
var client = AdlsClient.CreateClient(_adlsAccountName, accessToken);
using (var stream = client.CreateFile(fileName, IfExists.Overwrite))
{
byte[] textByteArray = Encoding.UTF8.GetBytes("Winter is coming! \r\n");
stream.Write(textByteArray, 0, textByteArray.Length);
}
My code fails with the following error.
with exception Microsoft.Azure.DataLake.Store.AdlsException: Error in creating file /Path/tempFile0.txt.
**Operation: CREATE failed with HttpStatus:Unauthorized Error: Uexpected error in JSON parsing.**
Last encountered exception thrown after 1 tries. [Uexpected error in JSON parsing]
[ServerRequestId:<Some ID>]
at Microsoft.Azure.DataLake.Store.AdlsClient.CreateFile(String filename, IfExists mode, String octalPermission, Boolean createParent)