public bool TestCapacity(string resourceGroupName, string capacityName, out PSPowerBIEmbeddedCapacity capacity) { try { capacity = GetCapacity(resourceGroupName, capacityName); return(true); } catch (CloudException ex) { if ((ex.Response != null && ex.Response.StatusCode == HttpStatusCode.NotFound) || ex.Message.Contains(string.Format(Properties.Resources.FailedToDiscoverResourceGroup, capacityName, _subscriptionId))) { capacity = null; return(false); } throw; } }
public PSPowerBIEmbeddedCapacity CreateOrUpdateCapacity( string resourceGroupName, string capacityName, string location, string skuName = null, Hashtable customTags = null, string[] administrator = null, PSPowerBIEmbeddedCapacity existingCapacity = null) { if (string.IsNullOrEmpty(resourceGroupName)) { resourceGroupName = GetResourceGroupByCapacity(capacityName); } var tags = (customTags != null) ? TagsConversionHelper.CreateTagDictionary(customTags, true) : null; var adminList = new List <string>(); if (administrator != null && !string.IsNullOrEmpty(administrator[0])) { adminList.AddRange(administrator.ToList()); if (adminList.Count == 0) { adminList.Add(_currentUser); } } DedicatedCapacity newOrUpdatedCapacity = null; if (existingCapacity != null) { var updateParameters = new DedicatedCapacityUpdateParameters() { Sku = skuName == null ? null : GetResourceSkuFromName(skuName), Tags = tags, }; if (adminList.Count > 0) { updateParameters.Administration = new DedicatedCapacityAdministrators(adminList); } newOrUpdatedCapacity = _client.Capacities.Update(resourceGroupName, capacityName, updateParameters); } else { newOrUpdatedCapacity = _client.Capacities.Create( resourceGroupName, capacityName, new DedicatedCapacity() { Administration = new DedicatedCapacityAdministrators(adminList), Location = location, Sku = GetResourceSkuFromName(skuName), Tags = tags }); } return(new PSPowerBIEmbeddedCapacity(newOrUpdatedCapacity)); }