コード例 #1
0
 /// <summary>
 /// Creates or updates the plan
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.AzureStack.Management.IManagedPlanOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. Resource group name
 /// </param>
 /// <param name='parameters'>
 /// Required. Plan properties
 /// </param>
 /// <returns>
 /// Result for the create or update operation of the plan
 /// </returns>
 public static ManagedPlanCreateOrUpdateResult CreateOrUpdate(this IManagedPlanOperations operations, string resourceGroupName, ManagedPlanCreateOrUpdateParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IManagedPlanOperations)s).CreateOrUpdateAsync(resourceGroupName, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
コード例 #2
0
ファイル: SetPlan.cs プロジェクト: dulems/azure-powershell
 /// <summary>
 /// Executes the API call(s) against Azure Resource Management API(s).
 /// </summary>
 protected override object ExecuteCore()
 {
     using (var client = this.GetAzureStackClient(this.SubscriptionId))
     {
         this.WriteVerbose(Resources.UpdatingPlan.FormatArgs(this.Plan.Name, this.ResourceGroup));
         var parameters = new ManagedPlanCreateOrUpdateParameters(this.Plan);
         return client.ManagedPlans.CreateOrUpdate(this.ResourceGroup, parameters).Plan;
     }
 }
コード例 #3
0
        /// <summary>
        /// Executes the API call(s) against Azure Resource Management API(s).
        /// </summary>
        protected override object ExecuteCore()
        {
            this.WriteVerbose(Resources.CreatingNewPlan.FormatArgs(this.Name, this.ResourceGroup));
            using (var client = this.GetAzureStackClient(this.SubscriptionId))
            {
                // Ensure the resource group is created
                client.ResourceGroups.CreateOrUpdate(new ResourceGroupCreateOrUpdateParameters()
                {
                    ResourceGroup = new ResourceGroupDefinition()
                    {
                        Location = this.ArmLocation,
                        Name = this.ResourceGroup,
                    }
                });

                // TODO - determine what properties are needed
                var parameters = new ManagedPlanCreateOrUpdateParameters()
                {
                    Plan = new AdminPlanModel()
                    {
                        Name = this.Name,
                        Location = this.ArmLocation,
                        Properties = new AdminPlanDefinition()
                        {
                            Name = this.Name,
                            DisplayName = this.DisplayName,
                            State = this.State,
                            ServiceQuotas = new ServiceQuotaDefinition[0],
                        }
                    }
                };

                if (client.ManagedPlans.List(this.ResourceGroup, includeDetails: false).Plans
                    .Any(p => string.Equals(p.Properties.Name, parameters.Plan.Properties.Name, StringComparison.OrdinalIgnoreCase)))
                {
                    throw new PSInvalidOperationException(Resources.ManagedPlanAlreadyExists.FormatArgs(parameters.Plan.Properties.Name, this.ResourceGroup));
                }

                return client.ManagedPlans.CreateOrUpdate(this.ResourceGroup, parameters).Plan;
            }
        }
コード例 #4
0
 /// <summary>
 /// Creates or updates the plan
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.AzureStack.Management.IManagedPlanOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. Resource group name
 /// </param>
 /// <param name='parameters'>
 /// Required. Plan properties
 /// </param>
 /// <returns>
 /// Result for the create or update operation of the plan
 /// </returns>
 public static Task<ManagedPlanCreateOrUpdateResult> CreateOrUpdateAsync(this IManagedPlanOperations operations, string resourceGroupName, ManagedPlanCreateOrUpdateParameters parameters)
 {
     return operations.CreateOrUpdateAsync(resourceGroupName, parameters, CancellationToken.None);
 }