访问 blob ;不使用网络角色?

发布于 2024-08-28 11:08:01 字数 152 浏览 10 评论 0原文

我想知道是否有办法上传/下载 blob;添加删除视图元数据而不使用网络角色?如果我的应用程序有很多 gui,是否应该有多个 webrole?我到处都看到 webrole 的文件 default.aspx.cs 与基于事件的 blob 有关;这完全没问题,但是如果我的 gui 更复杂怎么办?

I wanted to knw if there is way we can upload /download a blob; add remove view metadata without using a webrole ? If my application has a lot of gui, shud there be multiple webroles ? everywhere I see webrole's file default.aspx.cs has everything to do with the blob based on a event ; which is perfectly fine, but what if my gui is more complicated ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

陌上青苔 2024-09-04 11:08:01

Blob 可以通过 REST 调用访问,因此如果您愿意,您实际上可以使用本地桌面应用程序操作 Blob,甚至可以使用 PHP 或 Java 编写。

至于网络角色:每个角色只是一个运行在某个服务器上的虚拟机。 Web 角色就像辅助角色一样,只是添加了 IIS。如果您有一个网站,您可以将整个网站放在一个 webrole 中。如果您需要扩展它以处理更多用户,您可以创建该网络角色的多个“实例” - 然后您网站的所有请求都会发送到各个实例,每个实例都运行相同的代码。 (是的,您可以为给定的应用程序拥有多个网络角色 - 这可能很实用,具体取决于您网站的复杂性,或者您对管理员和访问者有完全不同的 UI)。

Blobs are accessible via REST calls, so you can actually manipulate blobs with a local desktop app if you wish, even written in PHP or Java.

As for webroles: each role is simply a virtual machine running on some server somewhere. Web roles are just like worker roles, with the addition of IIS. If you have a website, you can put the entire website in a single webrole. If you need to scale it to handle more users, you could create more than one "instance" of that webrole - and then all of your website's requests get sent to the various instances, each running the same code. (yes, you could have multiple webroles for a given app - this might be practical depending on your site's complexity, or if you have a completely different UI for administrators vs visitors).

望笑 2024-09-04 11:08:01

不需要使用 Web 角色来访问 Azure 存储(Blob 或其他)。你可以使用辅助角色,甚至可以从桌面上运行的 Windows 窗体应用程序或不在 Azure 上运行的 Web/服务应用程序访问它。

有关如何访问 Azure 存储的信息,请参阅 Azure SDK 的 StorageClient 文档 - 这非常简单。

You don't need to use a web role to access Azure Storage (Blob or otherwise). You can use a worker role, or you can even access it from a Windows Forms app running on a desktop, or a web/service app which isn't running on Azure.

See the Azure SDK's StorageClient documentation for info on how to access Azure Storage - it's pretty easy.

笙痞 2024-09-04 11:08:01

您不需要 Azure 项目或其他角色来使用 blob。如果您想在.Net项目中使用Azure客户端,您可以将您的配置添加到应用程序设置部分并引用它。 Azure 客户端是休息调用的包装器。他们有一些请求签名步骤,这使得使用简单的网络请求很难实现调用。

 <add key="AzureBlobStorage" value="AccountName=youraccountname;AccountKey=YOURKEYeZgfgdfg==;DefaultEndpointsProtocol=https"/>

您可以获得 blob 客户端:

 public CloudBlobClient GetBlobClient()
    {
        var accountBlob = ConfigurationManager.AppSettings["AzureBlobStorage"];

        var account = CloudStorageAccount.Parse(accountBlob.ToString());


        return account.CreateCloudBlobClient();

    }


public CloudBlob GetBlob(BlobItem blobItem)
        {
            var client = GetBlobClient();
            var cloudBlobContainer = client.GetContainerReference(blobItem.ContainerReference);
            return cloudBlobContainer.GetBlobReference(blobItem.FileName);
        }

BlobItem 只是一个包装器。基本上,您需要文件夹名称和文件名才能访问 blob。

 public class BlobItem
{
    [Required]
    [Display(Name = "Container")]
    public string ContainerReference { get; set; }
    [Required]
    [Display(Name = "File name")]
    public string FileName { get; set; }

    [Required]
    [UIHint("MultilineText")]
    public string Content { get; set; }

    /// <summary>
    /// to use in stream mode
    /// </summary>
    public Stream Stream { get; set; }
}

You don't need Azure project or other roles to use blob. If you want to use Azure client in .Net project, you can add your config to app settings section and reference it. Azure client is a wrapper to rest calls. They have some request signing steps which make the calls difficult to implement with simple webrequests.

 <add key="AzureBlobStorage" value="AccountName=youraccountname;AccountKey=YOURKEYeZgfgdfg==;DefaultEndpointsProtocol=https"/>

You can get the blob client:

 public CloudBlobClient GetBlobClient()
    {
        var accountBlob = ConfigurationManager.AppSettings["AzureBlobStorage"];

        var account = CloudStorageAccount.Parse(accountBlob.ToString());


        return account.CreateCloudBlobClient();

    }


public CloudBlob GetBlob(BlobItem blobItem)
        {
            var client = GetBlobClient();
            var cloudBlobContainer = client.GetContainerReference(blobItem.ContainerReference);
            return cloudBlobContainer.GetBlobReference(blobItem.FileName);
        }

BlobItem is just a wrapper. Basically, you need folder name and filename to access a blob.

 public class BlobItem
{
    [Required]
    [Display(Name = "Container")]
    public string ContainerReference { get; set; }
    [Required]
    [Display(Name = "File name")]
    public string FileName { get; set; }

    [Required]
    [UIHint("MultilineText")]
    public string Content { get; set; }

    /// <summary>
    /// to use in stream mode
    /// </summary>
    public Stream Stream { get; set; }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文