简体   繁体   English

F#和AzureStorage GetBlobContainer

[英]F# and AzureStorage GetBlobContainer

Has anyone used the WindowsAzure.Storage NuGet package in a F# project? 是否有人在F#项目中使用WindowsAzure.Storage NuGet软件包? I am trying to upload a photo to Azure storage using this code: 我正在尝试使用以下代码将照片上传到Azure存储:

member this.InsertPhotoImage(photoImage: PhotoImage) =
    let storageAccount = CloudStorageAccount.Parse(connectionString)
    let blobClient = storageAccount.CreateCloudBlobClient()
    let container = this.GetBlobContainer(blobClient) 
    let photoUri = this.GetPhotoImageUri(photoImage.UniqueId)
    let blockBlob = container.GetBlockBlobReference(photoUri) 
    use memoryStream = new MemoryStream(photoImage.ImageBytes)
    blockBlob.UploadFromStream(memoryStream)

and I am getting this exception on the container.GetBlockBlobReference and blockBlob.UploadFromStream lines: Lookup on object of indeterminate type based on information prior to this program point. 我在container.GetBlockBlobReference和blockBlob.UploadFromStream行上收到此异常: 基于此程序点之前的信息,对不确定类型的对象进行查找。

When I do an explicit cast like this on this line 当我在此行上进行像这样的显式转换时

    let container = this.GetBlobContainer(blobClient) :> CloudBlobContainer

It compiles but I get this warning: 它可以编译,但是我得到这个警告:

The type 'CloudBlobContainer' does not have any proper subtypes and need not be used as the target of a static coercion 类型“ CloudBlobContainer”没有任何适当的子类型,因此不需要用作静态强制的目标

Thanks in advance 提前致谢

OK, it is a problem with me and the step-down rule 好吧,这是我和降级规则的问题

I need to create the helper functions (in this case GetBlobContainer) BEFORE using them. 在使用它们之前,我需要创建辅助函数(在本例中为GetBlobContainer)。

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

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