Пример #1
0
        public static async Task <AzureResourceProperties> CreateStorageAsync()
        {
            var subscription  = TestUtility.EventHubsSubscription;
            var resourceGroup = TestUtility.EventHubsResourceGroup;
            var token         = await AquireManagementTokenAsync();

            string CreateName() => $"neteventhubstrackone{ Guid.NewGuid().ToString("D").Substring(0, 4) }";

            using (var client = new StorageManagementClient(TestUtility.ResourceManager, new TokenCredentials(token))
            {
                SubscriptionId = subscription
            })
            {
                var location = await QueryResourceGroupLocationAsync(token, resourceGroup, subscription);

                var sku            = new StorageManagement.Sku(StorageManagement.SkuName.StandardLRS, StorageManagement.SkuTier.Standard);
                var parameters     = new StorageManagement.StorageAccountCreateParameters(sku, StorageManagement.Kind.BlobStorage, location: location, tags: GetResourceTags(), accessTier: StorageManagement.AccessTier.Hot);
                var storageAccount = await CreateRetryPolicy <StorageManagement.StorageAccount>().ExecuteAsync(() => client.StorageAccounts.CreateAsync(resourceGroup, CreateName(), parameters));

                var storageKeys = await CreateRetryPolicy <StorageManagement.StorageAccountListKeysResult>().ExecuteAsync(() => client.StorageAccounts.ListKeysAsync(resourceGroup, storageAccount.Name));

                return(new AzureResourceProperties(storageAccount.Name, $"DefaultEndpointsProtocol=https;AccountName={ storageAccount.Name };AccountKey={ storageKeys.Keys[0].Value };EndpointSuffix={ TestUtility.StorageEndpointSuffix }", true));
            }
        }
 /// <summary>
 /// Initializes a new instance of the BlobServiceProperties class.
 /// </summary>
 /// <param name="id">Fully qualified resource ID for the resource. Ex -
 /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}</param>
 /// <param name="name">The name of the resource</param>
 /// <param name="type">The type of the resource. E.g.
 /// "Microsoft.Compute/virtualMachines" or
 /// "Microsoft.Storage/storageAccounts"</param>
 /// <param name="cors">Specifies CORS rules for the Blob service. You
 /// can include up to five CorsRule elements in the request. If no
 /// CorsRule elements are included in the request body, all CORS rules
 /// will be deleted, and CORS will be disabled for the Blob
 /// service.</param>
 /// <param name="defaultServiceVersion">DefaultServiceVersion indicates
 /// the default version to use for requests to the Blob service if an
 /// incoming request’s version is not specified. Possible values
 /// include version 2008-10-27 and all more recent versions.</param>
 /// <param name="deleteRetentionPolicy">The blob service properties for
 /// blob soft delete.</param>
 /// <param name="isVersioningEnabled">Versioning is enabled if set to
 /// true.</param>
 /// <param name="automaticSnapshotPolicyEnabled">Deprecated in favor of
 /// isVersioningEnabled property.</param>
 /// <param name="changeFeed">The blob service properties for change
 /// feed events.</param>
 /// <param name="restorePolicy">The blob service properties for blob
 /// restore policy.</param>
 /// <param name="containerDeleteRetentionPolicy">The blob service
 /// properties for container soft delete.</param>
 /// <param name="lastAccessTimeTrackingPolicy">The blob service
 /// property to configure last access time based tracking
 /// policy.</param>
 /// <param name="sku">Sku name and tier.</param>
 public BlobServiceProperties(string id = default(string), string name = default(string), string type = default(string), CorsRules cors = default(CorsRules), string defaultServiceVersion = default(string), DeleteRetentionPolicy deleteRetentionPolicy = default(DeleteRetentionPolicy), bool?isVersioningEnabled = default(bool?), bool?automaticSnapshotPolicyEnabled = default(bool?), ChangeFeed changeFeed = default(ChangeFeed), RestorePolicyProperties restorePolicy = default(RestorePolicyProperties), DeleteRetentionPolicy containerDeleteRetentionPolicy = default(DeleteRetentionPolicy), LastAccessTimeTrackingPolicy lastAccessTimeTrackingPolicy = default(LastAccessTimeTrackingPolicy), Sku sku = default(Sku))
     : base(id, name, type)
 {
     Cors = cors;
     DefaultServiceVersion          = defaultServiceVersion;
     DeleteRetentionPolicy          = deleteRetentionPolicy;
     IsVersioningEnabled            = isVersioningEnabled;
     AutomaticSnapshotPolicyEnabled = automaticSnapshotPolicyEnabled;
     ChangeFeed    = changeFeed;
     RestorePolicy = restorePolicy;
     ContainerDeleteRetentionPolicy = containerDeleteRetentionPolicy;
     LastAccessTimeTrackingPolicy   = lastAccessTimeTrackingPolicy;
     Sku = sku;
     CustomInit();
 }