/// <summary> /// Create / Update the location. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.AzureStack.Management.IManagedLocationOperations. /// </param> /// <param name='parameters'> /// Required. Location properties /// </param> /// <returns> /// The location update result. /// </returns> public static ManagedLocationCreateOrUpdateResult CreateOrUpdate(this IManagedLocationOperations operations, ManagedLocationCreateOrUpdateParameters parameters) { return Task.Factory.StartNew((object s) => { return ((IManagedLocationOperations)s).CreateOrUpdateAsync(parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
/// <summary> /// Updates the managed location with new values /// </summary> protected override object ExecuteCore() { using (var client = this.GetAzureStackClient(this.SubscriptionId)) { this.WriteVerbose(Resources.UpdatingManagedLocation.FormatArgs(this.Location.Name)); var parameters = new ManagedLocationCreateOrUpdateParameters(this.Location); return client.ManagedLocations.CreateOrUpdate(parameters).Location; } }
/// <summary> /// Creates a new location /// </summary> protected override object ExecuteCore() { using (var client = this.GetAzureStackClient(this.SubscriptionId)) { this.WriteVerbose(Resources.CreatingNewManagedLocation.FormatArgs(this.Name)); var parameters = new ManagedLocationCreateOrUpdateParameters() { Location = new Location() { DisplayName = this.DisplayName, Latitude = this.Latitude.ToString(CultureInfo.InvariantCulture), Longitude = this.Longitude.ToString(CultureInfo.InvariantCulture), Name = this.Name } }; if (client.ManagedLocations.List() .Locations.Any(location => location.Name.EqualsInsensitively(parameters.Location.Name))) { throw new PSInvalidOperationException(Resources.ManagedLocationAlreadyExists.FormatArgs(parameters.Location.Name)); } return client.ManagedLocations.CreateOrUpdate(parameters).Location; } }
/// <summary> /// Create / Update the location. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.AzureStack.Management.IManagedLocationOperations. /// </param> /// <param name='parameters'> /// Required. Location properties /// </param> /// <returns> /// The location update result. /// </returns> public static Task<ManagedLocationCreateOrUpdateResult> CreateOrUpdateAsync(this IManagedLocationOperations operations, ManagedLocationCreateOrUpdateParameters parameters) { return operations.CreateOrUpdateAsync(parameters, CancellationToken.None); }