示例#1
0
        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(WaitUntil.Completed, rgName, new ResourceGroupData(location));

            ResourceGroup resourceGroup = operation.Value;

            this.resourceGroup = resourceGroup;
            StorageSku  sku         = new StorageSku(StorageSkuName.StandardGRS);
            StorageKind kind        = StorageKind.Storage;
            string      locationStr = "westus2";
            StorageAccountCreateParameters parameters        = new StorageAccountCreateParameters(sku, kind, locationStr);
            StorageAccountCollection       accountCollection = resourceGroup.GetStorageAccounts();
            string accountName = "myAccount";
            ArmOperation <StorageAccount> accountCreateOperation = await accountCollection.CreateOrUpdateAsync(WaitUntil.Started, accountName, parameters);

            storageAccount = await accountCreateOperation.WaitForCompletionAsync();

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

            #endregion
            this.fileService = fileService;
        }
        public async Task CreateStorageAccountAndGetFileShareCollection()
        {
            _resourceGroup = await CreateResourceGroupAsync();

            string accountName = await CreateValidAccountNameAsync("teststoragemgmt");

            StorageAccountCollection storageAccountCollection = _resourceGroup.GetStorageAccounts();

            _storageAccount = (await storageAccountCollection.CreateOrUpdateAsync(true, accountName, GetDefaultStorageAccountParameters())).Value;
            _fileService    = _storageAccount.GetFileService();
            _fileService    = await _fileService.GetAsync();

            _fileShareCollection = _fileService.GetFileShares();
        }