public void UpdateStorageAccounts() { MediaService mediaServiceNew = new MediaService(); mediaServiceNew.ApiEndpoints = mediaService.ApiEndpoints; mediaServiceNew.StorageAccounts = new List <StorageAccount>(); // build the list of attached storage and remove from the list the ones the user wants to detach foreach (var stor in mediaService.StorageAccounts) { if ((bool)stor.IsPrimary || !StorageResourceIdToDetach.Contains(stor.Id)) // Default cannot be detached { mediaServiceNew.StorageAccounts.Add(new StorageAccount(id: stor.Id, isPrimary: stor.IsPrimary)); } } // storage attach foreach (var storId in StorageResourceIdToAttach) { mediaServiceNew.StorageAccounts.Add(new StorageAccount(id: storId, isPrimary: false)); } string accn = _credentials.ReturnAccountName(); mediaClient.MediaService.Update(AMSResourceGroup, _credentials.ReturnAccountName(), mediaServiceNew); }
public async Task UpdateStorageAccountsAsync() { // storage to detach foreach (var stor in mediaService.StorageAccounts.ToList()) { if (StorageResourceIdToDetach.Contains(stor.Id)) { mediaService.StorageAccounts.Remove(stor); } } // storage to attach foreach (var storId in StorageResourceIdToAttach) { mediaService.StorageAccounts.Add(new StorageAccount(StorageAccountType.Secondary, storId)); } await mediaClient.Mediaservices.UpdateAsync(_amsClient.credentialsEntry.ResourceGroup, _amsClient.credentialsEntry.AccountName, mediaService); }