简体   繁体   English

将领域同步与 Azure Functions 结合使用

[英]Using Realm Sync with Azure Functions

I'm trying to use Realm Cloud in an Azure Function but it keeps giving me an error:我正在尝试在 Azure 函数中使用 Realm Cloud,但它一直给我一个错误:

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

Is there a way to configure Azure Functions to have permissions to create files?有没有办法将 Azure Functions 配置为具有创建文件的权限? I'm new to Azure Functions, this is my first one so I'm not really sure of all the particulars.我是 Azure Functions 的新手,这是我的第一个,所以我不太确定所有的细节。

I have found one solution to this.我找到了一种解决方案。 Inside Azure function, you can only create any file or folder inside the temp folder.在 Azure 函数中,您只能在临时文件夹中创建任何文件或文件夹。 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.如果您不传递文件夹名称,它会尝试将其存储在您将收到访问错误的默认位置。

I am not familiar with Realm, but functions has permissions to interact with the file system by default.我对 Realm 不熟悉,但默认情况下,函数具有与文件系统交互的权限。 See these links for information on the app service file system (this applies for functions too): https://docs.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有关应用服务文件系统的信息,请参阅这些链接(这也适用于函数): https: //docs.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.如果函数是使用 run from package 部署的,那么 wwwroot 是只读的。 But since the path in the error message doesn't point to wwwroot, this is probably not the issue.但由于错误消息中的路径未指向 wwwroot,因此这可能不是问题。

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.也许检查一下领域是否有一个配置设置,可以让你指定它应该在哪个位置创建“领域对象服务器”。

您可以使用

SyncConfigurationBase.Initialize(UserPersistenceMode.NotEncrypted, basePath: Path.GetTempPath());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM