我正在部署具有文件上载方法的无状态API。 API使用者上载文件,文件存储在文件系统(网络共享)中,元数据存储在数据库中。
但是,当它部署到Azure环境时,我真的不知道如何配置服务以便能够访问支持SMB的Azure文件。 Service Fabric Mesh似乎支持文件卷驱动程序,但我没有使用服务网格。只是好旧的服务面料。
那么请您推荐一种不必重写我的文件i / o的方法,以便它可以在Azure中使用文件存储。
谢谢
你可以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)")