/// <summary> /// Updates an existing Batch account /// </summary> /// <param name="resourceGroupName">The name of the resource group the account is under. If unspecified, it will be looked up.</param> /// <param name="accountName">The account name</param> /// <param name="tags">New tags to associate with the account</param> /// <param name="autoStorageAccountId">The resource id of the storage account to be used for auto storage.</param> /// <returns>A BatchAccountContext object representing the updated account</returns> public virtual BatchAccountContext UpdateAccount(string resourceGroupName, string accountName, Hashtable tags, string autoStorageAccountId) { if (string.IsNullOrEmpty(resourceGroupName)) { // use resource mgr to see if account exists and then use resource group name to do the actual lookup resourceGroupName = GetGroupForAccount(accountName); } Dictionary <string, string> tagDictionary = TagsConversionHelper.CreateTagDictionary(tags, validate: true); // need to the location in order to call var getResponse = BatchManagementClient.BatchAccount.Get(resourceGroupName, accountName); AutoStorageBaseProperties autoStorage = (autoStorageAccountId == null) ? null : new AutoStorageBaseProperties { StorageAccountId = autoStorageAccountId }; var response = BatchManagementClient.BatchAccount.Create(resourceGroupName, accountName, new BatchAccountCreateParameters() { Location = getResponse.Location, Tags = tagDictionary, AutoStorage = autoStorage }); BatchAccountContext context = BatchAccountContext.ConvertAccountResourceToNewAccountContext(response, this.azureContext); return(context); }
/// <summary> /// Creates a new Batch account /// </summary> /// <param name="parameters">The parameters defining the Batch account to create.</param> /// <returns>A BatchAccountContext object representing the new account</returns> public virtual BatchAccountContext CreateAccount(AccountCreateParameters parameters) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } Dictionary <string, string> tagDictionary = TagsConversionHelper.CreateTagDictionary(parameters.Tags, validate: true); AutoStorageBaseProperties autoStorage = (string.IsNullOrEmpty(parameters.AutoStorageAccountId)) ? null : new AutoStorageBaseProperties { StorageAccountId = parameters.AutoStorageAccountId }; KeyVaultReference keyVaultRef = null; if (!string.IsNullOrEmpty(parameters.KeyVaultId) || !string.IsNullOrEmpty(parameters.KeyVaultUrl)) { keyVaultRef = new KeyVaultReference(parameters.KeyVaultId, parameters.KeyVaultUrl); } var response = BatchManagementClient.BatchAccount.Create(parameters.ResourceGroup, parameters.BatchAccount, new BatchAccountCreateParameters() { Location = parameters.Location, Tags = tagDictionary, AutoStorage = autoStorage, PoolAllocationMode = parameters.PoolAllocationMode, KeyVaultReference = keyVaultRef, PublicNetworkAccess = parameters.PublicNetworkAccess }); var context = BatchAccountContext.ConvertAccountResourceToNewAccountContext(response, this.azureContext); return(context); }
/// <summary> /// Creates a new Batch account /// </summary> /// <param name="resourceGroupName">The name of the resource group in which to create the account</param> /// <param name="accountName">The account name</param> /// <param name="location">The location to use when creating the account</param> /// <param name="tags">The tags to associate with the account</param> /// <param name="autoStorageAccountId">The resource id of the storage account to be used for auto storage.</param> /// <returns>A BatchAccountContext object representing the new account</returns> public virtual BatchAccountContext CreateAccount(string resourceGroupName, string accountName, string location, Hashtable[] tags, string autoStorageAccountId) { // use the group lookup to validate whether account already exists. We don't care about the returned // group name nor the exception if (GetGroupForAccountNoThrow(accountName) != null) { throw new CloudException(Resources.AccountAlreadyExists); } Dictionary <string, string> tagDictionary = Helpers.CreateTagDictionary(tags, validate: true); AutoStorageBaseProperties autoStorage = (string.IsNullOrEmpty(autoStorageAccountId)) ? null : new AutoStorageBaseProperties { StorageAccountId = autoStorageAccountId }; var response = BatchManagementClient.Account.Create(resourceGroupName, accountName, new BatchAccountCreateParameters() { Location = location, Tags = tagDictionary, AutoStorage = autoStorage }); var context = BatchAccountContext.ConvertAccountResourceToNewAccountContext(response); return(context); }
/// <summary> /// Creates a new Batch account /// </summary> /// <param name="resourceGroupName">The name of the resource group in which to create the account</param> /// <param name="accountName">The account name</param> /// <param name="location">The location to use when creating the account</param> /// <param name="tags">The tags to associate with the account</param> /// <param name="autoStorageAccountId">The resource id of the storage account to be used for auto storage.</param> /// <returns>A BatchAccountContext object representing the new account</returns> public virtual BatchAccountContext CreateAccount(string resourceGroupName, string accountName, string location, Hashtable tags, string autoStorageAccountId) { Dictionary <string, string> tagDictionary = TagsConversionHelper.CreateTagDictionary(tags, validate: true); AutoStorageBaseProperties autoStorage = (string.IsNullOrEmpty(autoStorageAccountId)) ? null : new AutoStorageBaseProperties { StorageAccountId = autoStorageAccountId }; var response = BatchManagementClient.BatchAccount.Create(resourceGroupName, accountName, new BatchAccountCreateParameters() { Location = location, Tags = tagDictionary, AutoStorage = autoStorage }); var context = BatchAccountContext.ConvertAccountResourceToNewAccountContext(response); return(context); }