c# - Azure 文件挂载到云服务

标签 c# azure file-storage azure-files

我关注了this教程和一切似乎在本地工作正常,但是当我在 Azure 上托管我的 Web 应用程序并尝试安装/访问文件存储时,我收到“访问被拒绝”,但我确信我的凭据是正确的,因为它们在本地工作。在 azure 环境中(授权方面)我必须添加一些额外的东西吗?

我怀疑这与本教程使用的 dll 可能在 azure 环境中不可用有关,如果这是问题,那么我将非常感激如何解决的问题链接/提示。

值得一提的是: Web 应用程序和文件存储位于 azure 上的同一区域。

谢谢!

最佳答案

正如 David Makogon 提到的,Azure 文件卷无法安装到 Azure Web App。

Would something like this learn.microsoft.com/en-us/rest/api/storageservices/… be appropriate?

如果我们要操作Azure文件存储中的文件。我建议您可以使用 Azure 文件存储 SDK 来执行此操作。我们还可以从 Develop for Azure Files with .NET 获取演示代码.

CloudFileClient fileClient = storageAccount.CreateCloudFileClient();

// Get a reference to the file share we created previously.
CloudFileShare share = fileClient.GetShareReference("logs");

// Ensure that the share exists.
if (share.Exists())
{
    // Get a reference to the root directory for the share.
    CloudFileDirectory rootDir = share.GetRootDirectoryReference();

    // Get a reference to the directory we created previously.
    CloudFileDirectory sampleDir = rootDir.GetDirectoryReference("CustomLogs");

    // Ensure that the directory exists.
    if (sampleDir.Exists())
    {
        // Get a reference to the file we created previously.
        CloudFile file = sampleDir.GetFileReference("Log1.txt");

        // Ensure that the file exists.
        if (file.Exists())
        {
            // Write the contents of the file to the console window.
            Console.WriteLine(file.DownloadTextAsync().Result);
        }
    }
}

关于c# - Azure 文件挂载到云服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50604291/

相关文章:

c++ - OpenCV FileStorage - 元素之间的错误 : Parsing error (icvYMLParseValue) Missing ,

c# - 如何直接在浏览器中打开 pdf 文件?

c# - 如何安排在 Hangfire 中的特定日期运行的作业

c# - 股票代码生成的表单无法正确显示

c# - 在 Azure 移动服务中使用离线数据同步时是否可以加密 SQLite 数据库?

c++ - 使用OpenCV在YAML文件中不能放置多个Mat对象

c# - 我的 C# XNA random() 函数没有返回我想要的值?

C# 生成 Azure 表存储 ConnectionString

azure - https kubernetes 部署的应用程序

php - 将文件复制并重命名到同一目录而不删除原始文件