Access to own storage using aio-lib-state and aio-lib-action failed

ursboller

MVP

09-09-2020

To have a local storage during development on own environment (see https://experienceleaguecommunities.adobe.com/t5/project-firefly-questions/aio-local-action-with-err...) I thought I could use my access to Azure and setup containers to be used in the sdk init.
But aio-lib-lifes failed with error like "request to url XXX failed - getaddrinfo EAI_AGAIN" and aio-lib-files succeded but I was not able to write any keys...

is there any documentation on how to setup MS Azure to handle aio-lib-files and aio-lib-state? is it possible to use this access when running the "aio app run --local"? thanks for any help in this case!

Accepted Solutions (1)

Accepted Solutions (1)

duypnguyen

Employee

09-09-2020

Hi @ursboller , I managed to init the State SDK and write / read operations with this.

const state = await stateLib.init({ cosmos: { endpoint, masterKey, databaseId, containerId, partitionKey } })

My "endpoint" value is like https://<tenant-name>.documents.azure.com:443.

Do you have the same?

hi @duypnguyen my endpoint looks as this. I don't think it's an issue with the connection for state, since there is no error (i just don't get any old values - means state.get returns always "undefined".

Update: can see that aio-lib-states writes the values into storage, but I can't read (returns "undefined") 

next update: We tried to access the Azure with Postman, were able to receive the list of values. but as soon as we tried to access a single ressource on ../docs/{docsId} there was an error like "Partition key XXX is invalid". so it looks like under the hood there is an issue with the "partition key", but whatever we tryed, it we didn't succeed.
Remark: we needed to add an additional header "x-ms-documentdb-partitionkey" to get so far ...

hi @ursboller, I was able to reproduce your issue by giving the "partition key path" any value other than "/partitionKey". I think you have to set this exact value to make it work. See screenshot.

If you want to customize this path, there might be a way in the Files SDK. But I'm yet to look into it.

Screen Shot 2020-09-10 at 12.45.29.png

@duypnguyen you are awesome!!! created a new collection with the defined partitionKey and it works like a charm!!! thanks a lot
Thanks for confirming, Urs. Great to hear!

@duypnguyen maybe you can give me a hint on the aio-lib-files:
I am able to init aio-lib-files and then with files.list() I can see the files and with files.read("xxx") I can read a file.
But the function files.write fails with the following error message:

 

@adobe/aio-lib-files:error {
  "sdk": "FilesLib",
  "sdkDetails": {
    "filePath": "mydir/test.txt",
    "contentType": "Buffer"
  },
  "code": "ERROR_BAD_CREDENTIALS",
  "message": "[FilesLib:ERROR_BAD_CREDENTIALS] cannot access `cloud storage provider`, make sure your credentials are valid"
  "stacktrace": "FilesLibError: [FilesLib:ERROR_BAD_CREDENTIALS] ...
}

 

any ideas what I need to change? seems strange to have read access but write doesn't work ... 
Update: I tested what happens if I change the "storageAccessKey" to have the wrong value. In this case I can't even access the existing file and I get the "ERROR_BAD_CREDENTIALS" already on the "files.list" function ... that means, my credentials seem to be all right and the issue is somewhere else...

Hi @ursboller - thanks for reporting the issue. I could reproduce it and open an issue here: https://github.com/adobe/aio-lib-files/issues/62. The team is aware and will verify it.

Answers (0)