/// <summary> /// Create a cloud service. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Scheduler.ICloudServiceOperations. /// </param> /// <param name='cloudServiceName'> /// Required. The cloud service name. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the Create cloud service operation. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static AzureOperationResponse BeginCreating(this ICloudServiceOperations operations, string cloudServiceName, CloudServiceCreateParameters parameters) { return Task.Factory.StartNew((object s) => { return ((ICloudServiceOperations)s).BeginCreatingAsync(cloudServiceName, parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
public void CreateCloudService(SubscriptionCloudCredentials credentials,string cloudServiceName) { var cloudServiceClient = new CloudServiceManagementClient(credentials); var cloudServiceCreateParameters = new CloudServiceCreateParameters { Description = cloudServiceParameters.Description, GeoRegion = cloudServiceParameters.GeoRegion, Label = cloudServiceParameters.Label }; cloudServiceClient.CloudServices.Create(cloudServiceName, cloudServiceCreateParameters); }
/// <summary> /// Create a cloud service. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Scheduler.ICloudServiceOperations. /// </param> /// <param name='cloudServiceName'> /// The cloud service name. /// </param> /// <param name='parameters'> /// Parameters supplied to the Create cloud service operation. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static OperationResponse BeginCreating(this ICloudServiceOperations operations, string cloudServiceName, CloudServiceCreateParameters parameters) { try { return operations.BeginCreatingAsync(cloudServiceName, parameters).Result; } catch (AggregateException ex) { if (ex.InnerExceptions.Count > 1) { throw; } else { throw ex.InnerException; } } }
/// <summary> /// Create a cloud service. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Scheduler.ICloudServiceOperations. /// </param> /// <param name='cloudServiceName'> /// The cloud service name. /// </param> /// <param name='parameters'> /// Parameters supplied to the Create cloud service operation. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static Task<OperationResponse> BeginCreatingAsync(this ICloudServiceOperations operations, string cloudServiceName, CloudServiceCreateParameters parameters) { return operations.BeginCreatingAsync(cloudServiceName, parameters, CancellationToken.None); }