简体   繁体   English

Azure容器权限

[英]Azure container permissions

Im reading this article . 我正在读这篇文章

I have an azure container called "test" that is set to private in azure. 我有一个名为“ test”的天蓝色容器,在天蓝色中设置为私有。 That container has a scorm package in it "121/HEEDENNL/story.html" 该容器中包含一个scorm程序包“ 121 / HEEDENNL / story.html”

I'm using the code below to set the permissions of the folder to read. 我正在使用下面的代码来设置文件夹的读取权限。 However that story.html file needs several other files to run properly. 但是,story.html文件需要其他几个文件才能正常运行。 The story page opens and doesn't return a 403 or 404. but the files it trying to reference to to make the page run properly are not loading. 故事页面将打开,并且不会返回403或404。但是,它试图引用以使页面正常运行的文件未加载。

How can I get all the files needed for story.html to run properly, be set to read access also? 如何获得Story.html正常运行所需的所有文件,还设置为读取访问权限?

I thought changing the containers permissions would allow that file to access the files needed. 我认为更改容器权限将允许该文件访问所需的文件。

What am I missing here? 我在这里想念什么?

    public ActionResult ViewContent(int id)
    {
        const string pageBlobName = "121/HEEDENNL/story.html";

        CloudStorageAccount storageAccount = Common.Constants.Azure.ConnectionStringUrl;

        CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
        //// Retrieve a reference to a container.
        // CloudBlobContainer learningModulContainer = blobClient.GetContainerReference(Common.Constants.Azure.LearningModulesContainerName);
        CloudBlobContainer learningModulContainer = blobClient.GetContainerReference("test");

        PrintBlobs(learningModulContainer);

        CloudBlockBlob myindexfile =  learningModulContainer.GetBlockBlobReference(pageBlobName);

        SharedAccessBlobPermissions permission = SharedAccessBlobPermissions.None;
        permission = SharedAccessBlobPermissions.Read;


        var token = GetSasForBlob(myindexfile, permission,30);
        //this isn't finished.....must get learning module
        var module = DataAccessService.Get<LearningModule>(id);

        var url = $"{Common.Constants.Azure.StorageAccountUrl}{"test"}/{module.ScormPackage.Path.Replace("index_lms", "story")}{token}";

        return Redirect(token);
    }

 public static string GetSasForBlob(CloudBlockBlob blob, SharedAccessBlobPermissions permission, int sasMinutesValid)
    {
       // var sasToken = blob.GetSharedAccessSignature(new SharedAccessBlobPolicy()
        var sasToken = blob.Container.GetSharedAccessSignature(new SharedAccessBlobPolicy()
        {
            Permissions = permission,
            SharedAccessStartTime = DateTime.UtcNow.AddMinutes(-15),
            SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(sasMinutesValid),
        });
        return string.Format(CultureInfo.InvariantCulture, "{0}{1}", blob.Uri, sasToken);
    }

How can I get all the files needed for story.html to run properly, be set to read access also? 如何获得Story.html正常运行所需的所有文件,还设置为读取访问权限?

Firstly, if possible, you could put these css&js&image etc files that your html page reference in a allow-public-access container . 首先,如果可能的话,您可以将html页面引用的这些css&js&image等文件放在allow-public-access容器中

Secondly, you could provide URL with SAS of the blob resource, and add reference like this in your html page. 其次,您可以为URL提供 blob资源的SAS ,并在html页面中添加这样的引用。

<link href="https://{storageaccount}.blob.core.windows.net/styles/Style1.css?st=2017-06-15T02%3A27%3A00Z&se=2017-06-30T02%3A27%3A00Z&sp=r&sv=2015-04-05&sr=b&sig=%2FWwN0F4qyoIH97d7znRKo9lcp84S4oahU9RBwHTnlXk%3D" rel="stylesheet" />

Besides, if you'd like to host your web app, you could try to use Azure app service . 此外,如果您希望托管Web应用程序,则可以尝试使用Azure应用程序服务

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM