3

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.

GBreen12
  • 1,832
  • 2
  • 20
  • 38

3 Answers3

2

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.

Amit Shahani
  • 94
  • 3
  • 12
1

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.

Paul Batum
  • 8,165
  • 5
  • 40
  • 45
  • Yeah I think this is the right path but I don't think Realm is flexible enough to get the job done in Functions. It basically creates the `realm-object-server` at the root directory which doesn't work in Functions. The question is will I run into the same issue if I try to create a Web API via an AppService, will I run into the same issue? I think I will. I may need to create a full fledge linux/windows image and run the API on that. What are your thoughts? – GBreen12 Aug 10 '19 at 23:34
  • did you get any solution for this? accessing realm object server in azure functions? @GBreen12 – Amit Shahani Mar 11 '20 at 09:00
  • @AmitShahani I haven't figured this out mostly because it's part of a side project I haven't touched in a year. When I get back into it I can try your suggestion. – GBreen12 Mar 11 '20 at 15:37
0

You can use

SyncConfigurationBase.Initialize(UserPersistenceMode.NotEncrypted, basePath: Path.GetTempPath());
pfedotovsky
  • 711
  • 2
  • 10
  • 23