示例#1
0
        public DefaultBlobContainerFactory(AzureBlobOptions azureBlobOptions)
        {
            CloudBlobClient blobClient;

            if (azureBlobOptions.ConnectionString != null &&
                CloudStorageAccount.TryParse(azureBlobOptions.ConnectionString, out CloudStorageAccount cloudStorageAccount))
            {
                blobClient = cloudStorageAccount.CreateCloudBlobClient();
            }
            else if (azureBlobOptions.BaseUri != null && azureBlobOptions.Token != null)
            {
                blobClient = new CloudBlobClient(azureBlobOptions.BaseUri, new StorageCredentials(azureBlobOptions.Token));
            }
            else
            {
                throw new ArgumentException("One of the following must be set: 'ConnectionString' or 'BaseUri'+'Token'!");
            }

            _container = blobClient.GetContainerReference(azureBlobOptions.DocumentContainer);
        }
 public AzureBlobFileProvider(AzureBlobOptions azureBlobOptions)
 {
     _blobContainerFactory = new DefaultBlobContainerFactory(azureBlobOptions);
 }