azure - 如何设置 azure fileshare 租赁文件的租赁期限?

标签 azure azure-files azure-storage-files fileshare storage-file-share

我正在尝试将购买的租赁的到期时间设置为 1 分钟。这是我的代码

var shareClient = new ShareClient(connectionString, "testfileshare");
shareClient.CreateIfNotExists();
var fileClient = shareClient.GetRootDirectoryClient().GetFileClient("test.xml"); 
var leaseClient = fileClient.GetShareLeaseClient();
                
leaseClient.Acquire(TimeSpan.FromSeconds(60));
 var leaseDuration = fileClient.GetProperties().Value.LeaseDuration;

通过上面的代码,leaseDuration 设置为无限。我想将其设置为 1 分钟。

最佳答案

无法设置文件共享中文件的租用期限。您只能获取文件的无限租约(尽管可以获取文件共享的有限租约)。

来自REST API documentation :

enter image description here

关于azure - 如何设置 azure fileshare 租赁文件的租赁期限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72994735/

相关文章:

azure - Azure 文件共享有限制吗?

azure - 允许不同订阅中的 vnet 之间进行通信

c# - 使用 MS Word 更新文件时,Azure 存储文件共享会丢失元数据

azure - 将 Azure Files 的文件夹挂载到 Kubernetes 中?

azure - 如何在不需要时在夜间/白天暂停或停止Azure APP服务?

python - 通过 Python SDK 将图像字节上传到 Azure Block Blob 时出现 UnicodeDecodeError

c# - 调试IIS随机疯狂内存使用情况

azure - 使用 Azure 函数将文件从 Azure Blob 存储复制到 Azure 文件存储

带有直接链接的 Azure 文件存储访问文档

azure - 获取有关 Azure 文件共享文件句柄的详细信息 - Get-AzStorageFileHandle