Using Realm Sync with Azure Functions

276 views Asked by At

I'm trying to use Realm Cloud in an Azure Function but it keeps giving me an error:

make_dir() failed: Permission denied Path: /realm-object-server/

Is there a way to configure Azure Functions to have permissions to create files? I'm new to Azure Functions, this is my first one so I'm not really sure of all the particulars.

3

There are 3 answers

0
Amit Shahani On

I have found one solution to this. Inside Azure function, you can only create any file or folder inside the temp folder. So if you use following sync configuration, it should work. It worked for me.

var configuration = new FullSyncConfiguration(new Uri("/~/<your-realm-name>", UriKind.Relative), _realmUser, Path.Combine(Path.GetTempPath(), "realm-object-server"));

So basically, here you are passing the folder name to store the realm locally. If you don't pass the folder name, it will try to store it in a default location where you will get the access error.

0
pfedotovsky On

You can use

SyncConfigurationBase.Initialize(UserPersistenceMode.NotEncrypted, basePath: Path.GetTempPath());
3
Paul Batum On

I am not familiar with Realm, but functions has permissions to interact with the file system by default. See these links for information on the app service file system (this applies for functions too): https://learn.microsoft.com/en-us/azure/app-service/operating-system-functionality#file-access https://github.com/projectkudu/kudu/wiki/Understanding-the-Azure-App-Service-file-system

If the function is deployed using run from package, then the wwwroot is readonly. But since the path in the error message doesn't point to wwwroot, this is probably not the issue.

My best guess is that the code that is failing is trying to write to in an inappropriate location. The information in the links above should help resolve that. Maybe check to see if realm has a config setting that lets you specify which location it should be creating "realm-object-server" in.