Ejemplo n.º 1
0
 internal FileServiceData(ResourceIdentifier id, string name, ResourceType type, Models.Sku sku, CorsRules cors, DeleteRetentionPolicy shareDeleteRetentionPolicy, ProtocolSettings protocolSettings) : base(id, name, type)
 {
     Sku  = sku;
     Cors = cors;
     ShareDeleteRetentionPolicy = shareDeleteRetentionPolicy;
     ProtocolSettings           = protocolSettings;
 }
Ejemplo n.º 2
0
        public async Task createStorageAccountAndGetBlobContainerCollection()
        {
            ArmClient    armClient    = new ArmClient(new DefaultAzureCredential());
            Subscription subscription = await armClient.GetDefaultSubscriptionAsync();

            string   rgName   = "myRgName";
            Location location = Location.WestUS2;
            ResourceGroupCreateOrUpdateOperation operation = await subscription.GetResourceGroups().CreateOrUpdateAsync(rgName, new ResourceGroupData(location));

            ResourceGroup resourceGroup = operation.Value;

            this.resourceGroup = resourceGroup;
            Sku    sku         = new Sku(SkuName.StandardGRS);
            Kind   kind        = Kind.Storage;
            string locationStr = "westus2";
            StorageAccountCreateParameters parameters        = new StorageAccountCreateParameters(sku, kind, locationStr);
            StorageAccountCollection       accountCollection = resourceGroup.GetStorageAccounts();
            string accountName = "myAccount";
            StorageAccountCreateOperation accountCreateOperation = await accountCollection.CreateOrUpdateAsync(accountName, parameters);

            storageAccount = await accountCreateOperation.WaitForCompletionAsync();

            #region Snippet:Managing_BlobContainers_GetBlobService
            BlobService blobService = storageAccount.GetBlobService();
            #endregion
            this.blobService = blobService;
        }
        public async Task createStorageAccountAndGetFileShareCollection()
        {
            ArmClient    armClient    = new ArmClient(new DefaultAzureCredential());
            Subscription subscription = await armClient.GetDefaultSubscriptionAsync();

            string        rgName   = "myRgName";
            AzureLocation location = AzureLocation.WestUS2;
            ArmOperation <ResourceGroup> operation = await subscription.GetResourceGroups().CreateOrUpdateAsync(true, rgName, new ResourceGroupData(location));

            ResourceGroup resourceGroup = operation.Value;

            this.resourceGroup = resourceGroup;
            Sku    sku         = new Sku(SkuName.StandardGRS);
            Kind   kind        = Kind.Storage;
            string locationStr = "westus2";
            StorageAccountCreateParameters parameters        = new StorageAccountCreateParameters(sku, kind, locationStr);
            StorageAccountCollection       accountCollection = resourceGroup.GetStorageAccounts();
            string accountName = "myAccount";
            ArmOperation <StorageAccount> accountCreateOperation = await accountCollection.CreateOrUpdateAsync(false, accountName, parameters);

            storageAccount = await accountCreateOperation.WaitForCompletionAsync();

            #region Snippet:Managing_FileShares_GetFileService
            FileService fileService = await storageAccount.GetFileService().GetAsync();

            #endregion
            this.fileService = fileService;
        }
Ejemplo n.º 4
0
        public async Task CreateLargeFileShareOnStorageAccount()
        {
            //create storage account and enable large share
            string accountName = await CreateValidAccountNameAsync(namePrefix);

            _resourceGroup = await CreateResourceGroupAsync();

            StorageAccountContainer storageAccountContainer = _resourceGroup.GetStorageAccounts();
            Sku sku = new Sku(SkuName.StandardLRS);
            StorageAccountCreateParameters parameters = GetDefaultStorageAccountParameters(sku: sku, kind: Kind.StorageV2);

            parameters.LargeFileSharesState = LargeFileSharesState.Enabled;
            StorageAccount account1 = (await storageAccountContainer.CreateOrUpdateAsync(accountName, parameters)).Value;

            VerifyAccountProperties(account1, false);

            //create file share with share quota 5200, which is allowed in large file shares
            string      fileShareName = Recording.GenerateAssetName("testfileshare");
            FileService fileService   = await account1.GetFileServices().GetAsync("default");

            FileShareContainer shareContainer = fileService.GetFileShares();
            FileShareData      shareData      = new FileShareData();

            shareData.ShareQuota = 5200;
            FileShareCreateOperation fileShareCreateOperation = await shareContainer.CreateOrUpdateAsync(fileShareName, shareData);

            FileShare share = await fileShareCreateOperation.WaitForCompletionAsync();

            Assert.AreEqual(share.Data.ShareQuota, shareData.ShareQuota);
        }
Ejemplo n.º 5
0
        public static StorageAccountCreateParameters GetDefaultStorageAccountParameters(Sku sku = null, Kind?kind = null, string location = null)
        {
            Sku    skuParameters      = sku ?? DefaultSkuNameStandardGRS;
            Kind   kindParameters     = kind ?? DefaultKindStorage;
            string locationParameters = location ?? DefaultLocationString;
            StorageAccountCreateParameters parameters = new StorageAccountCreateParameters(skuParameters, kindParameters, locationParameters);

            parameters.Tags.InitializeFrom(DefaultTags);
            return(parameters);
        }
        public static StorageAccountCreateParameters GetDefaultStorageAccountParameters(Sku sku = null, Kind?kind = null, string location = null)
        {
            Sku    skuParameters      = sku ?? DefaultSkuNameStandardGRS;
            Kind   kindParameters     = kind ?? DefaultKindStorage;
            string locationParameters = location ?? DefaultLocation;

            StorageAccountCreateParameters account = new StorageAccountCreateParameters(skuParameters, kindParameters, locationParameters)
            {
                Tags = DefaultTags,
            };

            return(account);
        }
Ejemplo n.º 7
0
 internal BlobServiceData(ResourceIdentifier id, string name, ResourceType type, SystemData systemData, Models.Sku sku, CorsRules cors, string defaultServiceVersion, DeleteRetentionPolicy deleteRetentionPolicy, bool?isVersioningEnabled, bool?automaticSnapshotPolicyEnabled, ChangeFeed changeFeed, RestorePolicyProperties restorePolicy, DeleteRetentionPolicy containerDeleteRetentionPolicy, LastAccessTimeTrackingPolicy lastAccessTimeTrackingPolicy) : base(id, name, type, systemData)
 {
     Sku  = sku;
     Cors = cors;
     DefaultServiceVersion          = defaultServiceVersion;
     DeleteRetentionPolicy          = deleteRetentionPolicy;
     IsVersioningEnabled            = isVersioningEnabled;
     AutomaticSnapshotPolicyEnabled = automaticSnapshotPolicyEnabled;
     ChangeFeed    = changeFeed;
     RestorePolicy = restorePolicy;
     ContainerDeleteRetentionPolicy = containerDeleteRetentionPolicy;
     LastAccessTimeTrackingPolicy   = lastAccessTimeTrackingPolicy;
 }
        public async Task CreateOrUpdate()
        {
            #region Snippet:Managing_StorageAccounts_CreateStorageAccount
            //first we need to define the StorageAccountCreateParameters
            Sku    sku      = new Sku(SkuName.StandardGRS);
            Kind   kind     = Kind.Storage;
            string location = "westus2";
            StorageAccountCreateParameters parameters = new StorageAccountCreateParameters(sku, kind, location);
            //now we can create a storage account with defined account name and parameters
            StorageAccountCollection accountCollection = resourceGroup.GetStorageAccounts();
            string accountName = "myAccount";
            StorageAccountCreateOperation accountCreateOperation = await accountCollection.CreateOrUpdateAsync(accountName, parameters);

            StorageAccount storageAccount = accountCreateOperation.Value;
            #endregion
        }
Ejemplo n.º 9
0
 internal StorageAccountData(ResourceIdentifier id, string name, ResourceType type, SystemData systemData, IDictionary <string, string> tags, AzureLocation location, Models.Sku sku, Kind?kind, ManagedServiceIdentity identity, ExtendedLocation extendedLocation, ProvisioningState?provisioningState, Endpoints primaryEndpoints, string primaryLocation, AccountStatus?statusOfPrimary, DateTimeOffset?lastGeoFailoverTime, string secondaryLocation, AccountStatus?statusOfSecondary, DateTimeOffset?creationTime, CustomDomain customDomain, SasPolicy sasPolicy, KeyPolicy keyPolicy, KeyCreationTime keyCreationTime, Endpoints secondaryEndpoints, Encryption encryption, AccessTier?accessTier, AzureFilesIdentityBasedAuthentication azureFilesIdentityBasedAuthentication, bool?enableHttpsTrafficOnly, NetworkRuleSet networkRuleSet, bool?isSftpEnabled, bool?isLocalUserEnabled, bool?isHnsEnabled, GeoReplicationStats geoReplicationStats, bool?failoverInProgress, LargeFileSharesState?largeFileSharesState, IReadOnlyList <PrivateEndpointConnectionData> privateEndpointConnections, RoutingPreference routingPreference, BlobRestoreStatus blobRestoreStatus, bool?allowBlobPublicAccess, MinimumTlsVersion?minimumTlsVersion, bool?allowSharedKeyAccess, bool?enableNfsV3, bool?allowCrossTenantReplication, bool?defaultToOAuthAuthentication, PublicNetworkAccess?publicNetworkAccess, ImmutableStorageAccount immutableStorageWithVersioning, AllowedCopyScope?allowedCopyScope) : base(id, name, type, systemData, tags, location)
 {
     Sku                 = sku;
     Kind                = kind;
     Identity            = identity;
     ExtendedLocation    = extendedLocation;
     ProvisioningState   = provisioningState;
     PrimaryEndpoints    = primaryEndpoints;
     PrimaryLocation     = primaryLocation;
     StatusOfPrimary     = statusOfPrimary;
     LastGeoFailoverTime = lastGeoFailoverTime;
     SecondaryLocation   = secondaryLocation;
     StatusOfSecondary   = statusOfSecondary;
     CreationTime        = creationTime;
     CustomDomain        = customDomain;
     SasPolicy           = sasPolicy;
     KeyPolicy           = keyPolicy;
     KeyCreationTime     = keyCreationTime;
     SecondaryEndpoints  = secondaryEndpoints;
     Encryption          = encryption;
     AccessTier          = accessTier;
     AzureFilesIdentityBasedAuthentication = azureFilesIdentityBasedAuthentication;
     EnableHttpsTrafficOnly     = enableHttpsTrafficOnly;
     NetworkRuleSet             = networkRuleSet;
     IsSftpEnabled              = isSftpEnabled;
     IsLocalUserEnabled         = isLocalUserEnabled;
     IsHnsEnabled               = isHnsEnabled;
     GeoReplicationStats        = geoReplicationStats;
     FailoverInProgress         = failoverInProgress;
     LargeFileSharesState       = largeFileSharesState;
     PrivateEndpointConnections = privateEndpointConnections;
     RoutingPreference          = routingPreference;
     BlobRestoreStatus          = blobRestoreStatus;
     AllowBlobPublicAccess      = allowBlobPublicAccess;
     MinimumTlsVersion          = minimumTlsVersion;
     AllowSharedKeyAccess       = allowSharedKeyAccess;
     EnableNfsV3 = enableNfsV3;
     AllowCrossTenantReplication    = allowCrossTenantReplication;
     DefaultToOAuthAuthentication   = defaultToOAuthAuthentication;
     PublicNetworkAccess            = publicNetworkAccess;
     ImmutableStorageWithVersioning = immutableStorageWithVersioning;
     AllowedCopyScope = allowedCopyScope;
 }
Ejemplo n.º 10
0
        public async Task GetStorageAccountLastSyncTime()
        {
            //create storage account
            string accountName1 = await CreateValidAccountNameAsync(namePrefix);

            _resourceGroup = await CreateResourceGroupAsync();

            StorageAccountContainer storageAccountContainer = _resourceGroup.GetStorageAccounts();
            Sku sku = new Sku(SkuName.StandardRagrs);
            StorageAccountCreateParameters parameters = GetDefaultStorageAccountParameters(sku: sku, kind: Kind.StorageV2);
            StorageAccount account = (await storageAccountContainer.CreateOrUpdateAsync(accountName1, parameters)).Value;

            Assert.AreEqual(SkuName.StandardRagrs, account.Data.Sku.Name);
            Assert.Null(account.Data.GeoReplicationStats);

            //expand
            account = await account.GetAsync(StorageAccountExpand.GeoReplicationStats);

            Assert.NotNull(account.Data.GeoReplicationStats);
            Assert.NotNull(account.Data.GeoReplicationStats.Status);
            Assert.NotNull(account.Data.GeoReplicationStats.LastSyncTime);
            Assert.NotNull(account.Data.GeoReplicationStats.CanFailover);
        }
Ejemplo n.º 11
0
        public async Task CreateStorageAccountWithFileStorage()
        {
            //create storage account with file storage
            string accountName = await CreateValidAccountNameAsync(namePrefix);

            _resourceGroup = await CreateResourceGroupAsync();

            StorageAccountContainer storageAccountContainer = _resourceGroup.GetStorageAccounts();
            Sku sku = new Sku(SkuName.PremiumLRS);
            StorageAccountCreateParameters parameters = GetDefaultStorageAccountParameters(sku: sku, kind: Kind.FileStorage);
            StorageAccount account1 = (await storageAccountContainer.CreateOrUpdateAsync(accountName, parameters)).Value;

            //validate
            VerifyAccountProperties(account1, false);
            Assert.AreEqual(Kind.FileStorage, account1.Data.Kind);
            Assert.AreEqual(SkuName.PremiumLRS, account1.Data.Sku.Name);
            //this storage account should only have endpoints on file
            Assert.IsNull(account1.Data.PrimaryEndpoints.Blob);
            Assert.IsNull(account1.Data.PrimaryEndpoints.Dfs);
            Assert.NotNull(account1.Data.PrimaryEndpoints.File);
            Assert.IsNull(account1.Data.PrimaryEndpoints.Table);
            Assert.IsNull(account1.Data.PrimaryEndpoints.Queue);
        }