我正在部署一个具有文件上传方法的无状态API。API使用者上传一个文件,该文件存储在文件系统(网络共享)中,元数据存储在数据库中。
然而,当它被部署到Azure环境时,我真的不知道如何配置该服务以能够访问支持SMB的Azure文件。Service Fabric mesh似乎支持文件卷驱动程序,但我没有使用service Mesh。只是很好的旧服务结构。
所以你能推荐一种不需要重写我的文件i/o的方法,这样它就可以在Azure的文件存储中工作了吗?
谢谢
发布于 2019-04-12 19:54:20
您可以对文件共享执行script装载。使用服务主体访问存储凭据,或将其置于配置中。将脚本作为服务的setup entry point运行。确保脚本运行idempotent。
$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)")https://stackoverflow.com/questions/55648612
复制相似问题