public override void ExecuteCmdlet() { IDictionary <string, string> tagPairs = null; if (Tag != null) { tagPairs = new Dictionary <string, string>(); foreach (string key in Tag.Keys) { tagPairs.Add(key, Tag[key].ToString()); } } var netAppAccountBody = new NetAppAccount() { Location = Location, ActiveDirectories = (ActiveDirectory != null) ? ActiveDirectory.ConvertFromPs() : null, Tags = tagPairs }; if (ShouldProcess(Name, string.Format(PowerShell.Cmdlets.NetAppFiles.Properties.Resources.CreateResourceMessage, ResourceGroupName))) { var anfAccount = AzureNetAppFilesManagementClient.Accounts.CreateOrUpdate(netAppAccountBody, ResourceGroupName, Name); WriteObject(anfAccount.ToPsNetAppFilesAccount()); } }
public override void ExecuteCmdlet() { IDictionary <string, string> tagPairs = null; if (Tag != null) { tagPairs = new Dictionary <string, string>(); foreach (string key in Tag.Keys) { tagPairs.Add(key, Tag[key].ToString()); } } NetAppAccount existingAccount = null; try { existingAccount = AzureNetAppFilesManagementClient.Accounts.Get(ResourceGroupName, Name); } catch { existingAccount = null; } if (existingAccount != null) { throw new AzPSResourceNotFoundCloudException($"A NetAppAccount with name '{this.Name}' in resource group '{this.ResourceGroupName}' already exists. Only one active directory allowed. Please use Set/Update-AzNetAppFilesAccount to update an existing NetAppAccount."); } var netAppAccountBody = new NetAppAccount() { Location = Location, ActiveDirectories = (ActiveDirectory != null) ? ActiveDirectory.ConvertFromPs() : null, Tags = tagPairs }; if (ShouldProcess(Name, string.Format(PowerShell.Cmdlets.NetAppFiles.Properties.Resources.CreateResourceMessage, ResourceGroupName))) { var anfAccount = AzureNetAppFilesManagementClient.Accounts.CreateOrUpdate(netAppAccountBody, ResourceGroupName, Name); WriteObject(anfAccount.ToPsNetAppFilesAccount()); } }
public override void ExecuteCmdlet() { IDictionary <string, string> tagPairs = null; if (Tag != null) { tagPairs = new Dictionary <string, string>(); foreach (string key in Tag.Keys) { tagPairs.Add(key, Tag[key].ToString()); } } if (ParameterSetName == ResourceIdParameterSet) { var resourceIdentifier = new ResourceIdentifier(this.ResourceId); ResourceGroupName = resourceIdentifier.ResourceGroupName; Name = resourceIdentifier.ResourceName; } else if (ParameterSetName == ObjectParameterSet) { ResourceGroupName = InputObject.ResourceGroupName; Name = InputObject.Name; } var netAppAccountBody = new NetAppAccountPatch() { Location = Location, ActiveDirectories = (ActiveDirectory != null) ? ActiveDirectory.ConvertFromPs() : null, Tags = tagPairs, }; if (ShouldProcess(Name, string.Format(PowerShell.Cmdlets.NetAppFiles.Properties.Resources.UpdateResourceMessage, ResourceGroupName))) { var anfAccount = AzureNetAppFilesManagementClient.Accounts.Update(netAppAccountBody, ResourceGroupName, Name); WriteObject(anfAccount.ToPsNetAppFilesAccount()); } }