首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何为在Azure service Fabric群集中运行的无状态服务提供文件共享?

如何为在Azure service Fabric群集中运行的无状态服务提供文件共享?
EN

Stack Overflow用户
提问于 2019-04-12 17:32:00
回答 1查看 430关注 0票数 0

我正在部署一个具有文件上传方法的无状态API。API使用者上传一个文件,该文件存储在文件系统(网络共享)中,元数据存储在数据库中。

然而,当它被部署到Azure环境时,我真的不知道如何配置该服务以能够访问支持SMB的Azure文件。Service Fabric mesh似乎支持文件卷驱动程序,但我没有使用service Mesh。只是很好的旧服务结构。

所以你能推荐一种不需要重写我的文件i/o的方法,这样它就可以在Azure的文件存储中工作了吗?

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-12 19:54:20

您可以对文件共享执行script装载。使用服务主体访问存储凭据,或将其置于配置中。将脚本作为服务的setup entry point运行。确保脚本运行idempotent

代码语言:javascript
复制
$resourceGroupName = "<your-resource-group-name>"
$storageAccountName = "<your-storage-account-name>"

# These commands require you to be logged into your Azure account, run Login-AzAccount if you haven't
# already logged in.
$storageAccount = Get-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccountName
$storageAccountKeys = Get-AzStorageAccountKey -ResourceGroupName $resourceGroupName -Name $storageAccountName

# The cmdkey utility is a command-line (rather than PowerShell) tool. We use Invoke-Expression to allow us to 
# consume the appropriate values from the storage account variables. The value given to the add parameter of the
# cmdkey utility is the host address for the storage account, <storage-account>.file.core.windows.net for Azure 
# Public Regions. $storageAccount.Context.FileEndpoint is used because non-Public Azure regions, such as sovereign 
# clouds or Azure Stack deployments, will have different hosts for Azure file shares (and other storage resources).
Invoke-Expression -Command ("cmdkey /add:$([System.Uri]::new($storageAccount.Context.FileEndPoint).Host) " + `
    "/user:AZURE\$($storageAccount.StorageAccountName) /pass:$($storageAccountKeys[0].Value)")
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55648612

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档