Search code examples
c#neo4jcypherneo4j-apoc

apoc.load.jsonParams with Azure Blob signed URL leads to http 403 error


I upload the json file with this code:

BlobClient blobClient = containerClient.GetBlobClient(fileName);

await using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(json)))
{
    response = await blobClient.UploadAsync(ms, new BlobUploadOptions
    {
        HttpHeaders = new BlobHttpHeaders
        {
            ContentType = "application/json",
            ContentEncoding = "UTF-8"
        }
    });
}

var absoluteUrl = string.Empty;
if (response.GetRawResponse().Status == 201)
{
    // 1 hour valid
    absoluteUrl = blobClient.GenerateSasUri(BlobSasPermissions.Read, DateTimeOffset.Now + TimeSpan.FromMinutes(60)).AbsoluteUri;
}

I'm able to open the file completely fine in Browser by entering the signed URL (absoluteUrl), but in Neo4J Cypher apoc.load.jsonParams call I got a http status 403:

CALL apoc.load.jsonParams("https://[ACCOUNTNAME].blob.core.windows.net/[CONTAINER]/[FILE]?sv=2021-04-10&se=2022-03-31T16%3A35%3A29Z&sr=b&sp=r&sig=[SIGNATURE]", null, null) YIELD value AS item

Have I forgotten anything?


Solution

  • Your problem could be related to Neo4j encoding your URL again. Thoroughly check the error message of Neo4j and check if for example %3D is replaced by %253D. If that's the case, you have to pass unescaped Uri to the apoc call by using for example Uri.UnescapeDataString(<yourUrl>).