本文整理匯總了C#中Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.SetPermissions方法的典型用法代碼示例。如果您正苦於以下問題:C# CloudBlobContainer.SetPermissions方法的具體用法?C# CloudBlobContainer.SetPermissions怎麽用?C# CloudBlobContainer.SetPermissions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer
的用法示例。
在下文中一共展示了CloudBlobContainer.SetPermissions方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: OnStart
public override bool OnStart()
{
// Set the maximum number of concurrent connections.
ServicePointManager.DefaultConnectionLimit = 12;
// Read database connection string and open database.
var dbConnString = CloudConfigurationManager.GetSetting("TCWAdminPortalDbConnectionString");
_dbContext = new TCWAdminContext(dbConnString);
// Open storage account using credentials from .cscfg file.
var storageAccount = CloudStorageAccount.Parse
(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
Trace.TraceInformation("Creating images blob container");
var blobClient = storageAccount.CreateCloudBlobClient();
_imagesBlobContainer = blobClient.GetContainerReference("images");
if (_imagesBlobContainer.CreateIfNotExists())
{
// Enable public access on the newly created "images" container.
_imagesBlobContainer.SetPermissions(
new BlobContainerPermissions
{
PublicAccess = BlobContainerPublicAccessType.Blob
});
}
Trace.TraceInformation("Creating images queue");
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
_imagesQueue = queueClient.GetQueueReference("images");
_imagesQueue.CreateIfNotExists();
Trace.TraceInformation("Storage initialized");
return base.OnStart();
}
示例2: InitializeContainer
public void InitializeContainer(string container)
{
var blobClient = StorageAccount.CreateCloudBlobClient();
blobContainer = blobClient.GetContainerReference(container);
blobContainer.CreateIfNotExists();
blobContainer.SetPermissions(new BlobContainerPermissions() { PublicAccess = BlobContainerPublicAccessType.Blob });
}
示例3: BlobStorage
public BlobStorage(BlobSettings appSettings)
{
try
{
if (appSettings.ImageSize != null)
ResizeLayer = new ResizeLayer(appSettings.ImageSize, ResizeMode.Min);
UploadThumbnail = appSettings.UploadThumbnail;
StorageAccountName = appSettings.StorageAccountName;
StorageAccountAccessKey = appSettings.StorageAccountAccessKey;
// Create a blob client and retrieve reference to images container
BlobClient = StorageAccount.CreateCloudBlobClient();
Container = BlobClient.GetContainerReference(appSettings.ContainerName);
// Create the "images" container if it doesn't already exist.
if (Container.CreateIfNotExists())
{
// Enable public access on the newly created "images" container
Container.SetPermissions(
new BlobContainerPermissions
{
PublicAccess =
BlobContainerPublicAccessType.Blob
});
}
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
}
示例4: HomeController
public HomeController()
{
storageAccount = CloudStorageAccount.Parse(
ConfigurationManager.AppSettings["StorageConnectionString"]);
tableClient = storageAccount.CreateCloudTableClient();
table = tableClient.GetTableReference("fouramigos");
table.CreateIfNotExists();
blobClient = storageAccount.CreateCloudBlobClient();
container = blobClient.GetContainerReference("fouramigos");
container.CreateIfNotExists();
BlobContainerPermissions permissions = container.GetPermissions();
permissions.PublicAccess = BlobContainerPublicAccessType.Container;
container.SetPermissions(permissions);
//lägga till nya
//var tablemodels = new TableModel("Brutus", "Uggla") { Location = "T4", Description="Uggla i träd", Type="Foto" };
//var tablemodels1 = new TableModel("brutus", "Örn") { Location = "T4", Description="Örn som flyger", Type = "Foto" };
//var opreation = TableOperation.Insert(tablemodels);
//var operation2 = TableOperation.Insert(tablemodels1);
//table.Execute(opreation);
//table.Execute(operation2);
}
示例5: BlobContainer
public BlobContainer(string name)
{
// hämta connectionsträngen från config // RoleEnviroment bestämmer settingvalue runtime
//var connectionString = RoleEnvironment.GetConfigurationSettingValue("PhotoAppStorage");
//var connectionString = CloudConfigurationManager.GetSetting("CloudStorageApp");
// hämtar kontot utfrån connectionsträngens värde
//var account = CloudStorageAccount.Parse(connectionString);
//var account = CloudStorageAccount.DevelopmentStorageAccount;
var cred = new StorageCredentials("jholm",
"/bVipQ2JxjWwYrZQfHmzhaBx1p1s8BoD/wX6VWOmg4/gpVo/aALrjsDUKqzXsFtc9utepPqe65NposrXt9YsyA==");
var account = new CloudStorageAccount(cred, true);
// skapar en blobclient
_client = account.CreateCloudBlobClient();
m_BlobContainer = _client.GetContainerReference(name);
// Om det inte finns någon container med det namnet
if (!m_BlobContainer.Exists())
{
// Skapa containern
m_BlobContainer.Create();
var permissions = new BlobContainerPermissions()
{
PublicAccess = BlobContainerPublicAccessType.Blob
};
// Sätter public access till blobs
m_BlobContainer.SetPermissions(permissions);
}
}
示例6: CopyBlobData
/// <summary>
/// Initiates the SolCat Azure blob data sync.
/// </summary>
public static void CopyBlobData()
{
// Authentication Credentials for Azure Storage:
var credsSrc
= new StorageCredentials(
ConfigHelper.GetConfigValue("HubContainerName"),
ConfigHelper.GetConfigValue("HubContainerKey"));
var credsDest
= new StorageCredentials(
ConfigHelper.GetConfigValue("NodeContainerKey"),
ConfigHelper.GetConfigValue("NodeContainerKey"));
// Source Container: Hub (Development)
_srcContainer =
new CloudBlobContainer(
new Uri(ConfigHelper.GetConfigValue("HubContainerUri")),
credsSrc);
// Destination Container: Node (Production)
_destContainer =
new CloudBlobContainer(
new Uri(ConfigHelper.GetConfigValue("NodeContainerUri")),
credsDest);
// Set permissions on the container:
var permissions = new BlobContainerPermissions {PublicAccess = BlobContainerPublicAccessType.Blob};
_srcContainer.SetPermissions(permissions);
_destContainer.SetPermissions(permissions);
// Call the blob copy master method:
CopyBlobs(_srcContainer, _destContainer);
}
示例7: AzureFileSystem
public AzureFileSystem(string containerName, string root, bool isPrivate, CloudStorageAccount storageAccount) {
// Setup the connection to custom storage accountm, e.g. Development Storage
_storageAccount = storageAccount;
ContainerName = containerName;
_root = String.IsNullOrEmpty(root) ? "": root + "/";
_absoluteRoot = Combine(Combine(_storageAccount.BlobEndpoint.AbsoluteUri, containerName), _root);
//using ( new HttpContextWeaver() )
{
BlobClient = _storageAccount.CreateCloudBlobClient();
// Get and create the container if it does not exist
// The container is named with DNS naming restrictions (i.e. all lower case)
Container = BlobClient.GetContainerReference(ContainerName);
Container.CreateIfNotExists();
Container.SetPermissions(isPrivate
? new BlobContainerPermissions
{PublicAccess = BlobContainerPublicAccessType.Off}
: new BlobContainerPermissions
{PublicAccess = BlobContainerPublicAccessType.Blob}); // deny listing
}
}
示例8: SetContainerPermission
protected void SetContainerPermission(CloudBlobContainer container, BlobContainerPublicAccessType perimssion)
{
container.SetPermissions(new BlobContainerPermissions
{
PublicAccess = perimssion
});
}
示例9: OpenAsync
public async Task OpenAsync(PartitionContext context)
{
if (!WebJobsHelper.RunAsWebJobs)
Console.WriteLine(string.Format("EventProcessor initialization. Partition: '{0}', Offset: '{1}'",
context.Lease.PartitionId, context.Lease.Offset));
partitionContext = context;
var retries = 3;
while (retries > 0)
{
var s = string.Empty;
try
{
retries--;
s = "storage";
storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["SigfoxDemoStorage"].ConnectionString);
var blobClient = storageAccount.CreateCloudBlobClient();
blobContainer = blobClient.GetContainerReference("device");
blobContainer.SetPermissions(new BlobContainerPermissions() { PublicAccess = BlobContainerPublicAccessType.Off });
blobContainer.CreateIfNotExists();
s = "cache";
cacheConnection = await ConnectionMultiplexer.ConnectAsync(ConfigurationManager.ConnectionStrings["SigfoxDemoCache"].ConnectionString);
cacheDatabase = cacheConnection.GetDatabase();
s = "database";
sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SigfoxDemoDatabase"].ConnectionString);
sqlConnection.Open();
sqlCommand = new SqlCommand("InsertMessage", sqlConnection) { CommandType = CommandType.StoredProcedure };
sqlCommand.Parameters.Add(new SqlParameter("@Device", SqlDbType.VarChar));
sqlCommand.Parameters.Add(new SqlParameter("@Data", SqlDbType.VarChar));
sqlCommand.Parameters.Add(new SqlParameter("@Mode", SqlDbType.TinyInt));
sqlCommand.Parameters.Add(new SqlParameter("@Periode", SqlDbType.TinyInt));
sqlCommand.Parameters.Add(new SqlParameter("@FrameType", SqlDbType.TinyInt));
sqlCommand.Parameters.Add(new SqlParameter("@Battery", SqlDbType.Float));
sqlCommand.Parameters.Add(new SqlParameter("@Temperature", SqlDbType.Float));
sqlCommand.Parameters.Add(new SqlParameter("@Humidity", SqlDbType.Float));
sqlCommand.Parameters.Add(new SqlParameter("@ILS", SqlDbType.Bit));
sqlCommand.Parameters.Add(new SqlParameter("@Light", SqlDbType.Float));
sqlCommand.Parameters.Add(new SqlParameter("@Version", SqlDbType.VarChar));
sqlCommand.Parameters.Add(new SqlParameter("@AlertCount", SqlDbType.Int));
sqlCommand.Parameters.Add(new SqlParameter("@TimeStamp", SqlDbType.DateTime));
sqlCommand.Parameters.Add(new SqlParameter("@Duplicate", SqlDbType.Bit));
sqlCommand.Parameters.Add(new SqlParameter("@Signal", SqlDbType.Float));
sqlCommand.Parameters.Add(new SqlParameter("@Station", SqlDbType.VarChar));
sqlCommand.Parameters.Add(new SqlParameter("@AvgSignal", SqlDbType.Float));
sqlCommand.Parameters.Add(new SqlParameter("@Latitude", SqlDbType.Float));
sqlCommand.Parameters.Add(new SqlParameter("@Longitude", SqlDbType.Float));
sqlCommand.Parameters.Add(new SqlParameter("@Rssi", SqlDbType.Float));
sqlCommand.Parameters.Add(new SqlParameter("@SeqNumber", SqlDbType.Int));
retries = 0;
}
catch (Exception e)
{
Console.Error.WriteLine("Error opening destination Event Hub: " + e.Message + "(" + s + ")");
if (retries == 0)
throw;
}
}
checkpointStopWatch = new Stopwatch();
checkpointStopWatch.Start();
}
示例10: createContainer
public void createContainer()
{
container = blobClient.GetContainerReference(Constants.blobContainerName);
if (container.CreateIfNotExists())
{
container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob });
}
}
示例11: setPublicPermissions
public void setPublicPermissions(CloudBlobContainer container, BlobContainerPublicAccessType Level)
{
container.SetPermissions(
new BlobContainerPermissions
{
PublicAccess = Level
});
}
示例12: BlobHelper
public BlobHelper(String container)
{
// get or create blobContainer to communicate with Azure storage service
var blobClient = StorageAccount.CreateCloudBlobClient();
blobContainer = blobClient.GetContainerReference(container);
blobContainer.CreateIfNotExists();
blobContainer.SetPermissions(new BlobContainerPermissions() { PublicAccess = BlobContainerPublicAccessType.Blob });
}
示例13: PhotoInBlob
public PhotoInBlob()
{
storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["StorageConnection"].ConnectionString);
blobClinet = storageAccount.CreateCloudBlobClient();
blobContainer = blobClinet.GetContainerReference(ConfigurationManager.AppSettings["blobContainer"].ToString());
if(blobContainer.CreateIfNotExists())
{
blobContainer.SetPermissions(new BlobContainerPermissions() { PublicAccess = BlobContainerPublicAccessType.Blob });
}
}
示例14: AzureFileSystem
public AzureFileSystem(CloudBlobContainer container)
{
// this is not the constructor you're looking for
this.container = container;
container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Container });
container.CreateIfNotExists();
CreateDirectory("");
}
示例15: GetImageUrl
/// <summary>
/// Returns the Url of the given File object
/// </summary>
public static string GetImageUrl(Models.File file)
{
_container = _blobClient.GetContainerReference(file.Container);
_container.CreateIfNotExists();
_container.SetPermissions(
new BlobContainerPermissions
{
PublicAccess = BlobContainerPublicAccessType.Blob
});
return _container.GetBlockBlobReference(file.Key).Uri.ToString();
}