使用Azure函数C#将JSON存储在Blob存储上

时间:2019-04-04 10:41:32

标签: c# azure-storage-blobs

我想使用azure函数c#将json存储在blob存储上

例如,我的json是:

override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {

    let sectionHeaderView : UIView = UIView()

    let sectionHeaderImage: UIImage = UIImage(named: "Flag - ENGLAND.png")!
    let sectionHeaderImageView : UIImageView = UIImageView(image: sectionHeaderImage)
    sectionHeaderImageView.translatesAutoresizingMaskIntoConstraints = false

    let imageViewWidthConstraint : NSLayoutConstraint = NSLayoutConstraint(item: sectionHeaderImageView, attribute: .width, relatedBy: .equal, toItem: sectionHeaderImageView, attribute: .width, multiplier: 0.0, constant: 40)
    imageViewWidthConstraint.isActive = true
    sectionHeaderImageView.addConstraint(imageViewWidthConstraint)

    let imageViewHeightConstraint : NSLayoutConstraint = NSLayoutConstraint(item: sectionHeaderImageView, attribute: .height, relatedBy: .equal, toItem: sectionHeaderImageView, attribute: .height, multiplier: 0.0, constant: 40)
    imageViewHeightConstraint.isActive = true
    sectionHeaderImageView.addConstraint(imageViewHeightConstraint)

    let imageViewLeadingConstraint : NSLayoutConstraint = NSLayoutConstraint(item: sectionHeaderImageView, attribute: .leading, relatedBy: .equal, toItem: sectionHeaderView, attribute: .left, multiplier: 1.0, constant: 50)
    imageViewLeadingConstraint.isActive = true
    sectionHeaderImageView.addConstraint(imageViewLeadingConstraint)

    return sectionHeaderView
}

我想写入文件,甚至从文件中读取。

是否有使用Azure函数c#写入和读取文件的示例?

谢谢

1 个答案:

答案 0 :(得分:0)

看看CloudStorageAccount类:

https://docs.microsoft.com/en-us/dotnet/api/microsoft.windowsazure.storage.cloudstorageaccount?view=azure-dotnet

使用这些可以创建CloudBlobClientCloudBlobContainer。然后是CloudBlockBlob类:

https://docs.microsoft.com/en-us/dotnet/api/microsoft.windowsazure.storage.blob.cloudblockblob?view=azure-dotnet

使用CloudBlockBlob类:

CloudBlockBlob.UploadFromByteArray(...)上传,和cloudBlockBlob.DownloadToByteArray(...)下载文件。