/// <summary>
 /// Your documentation here.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/XXXXX.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.AzureStack.Management.IManagedOfferOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. Your documentation here.
 /// </param>
 /// <param name='parameters'>
 /// Required. Your documentation here.
 /// </param>
 /// <returns>
 /// Your documentation here.
 /// </returns>
 public static ManagedOfferCreateOrUpdateResult CreateOrUpdate(this IManagedOfferOperations operations, string resourceGroupName, ManagedOfferCreateOrUpdateParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IManagedOfferOperations)s).CreateOrUpdateAsync(resourceGroupName, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
示例#2
0
 /// <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.UpdatingOffer.FormatArgs(this.Offer.Name, this.ResourceGroup));
         var parameters = new ManagedOfferCreateOrUpdateParameters(this.Offer);
         return client.ManagedOffers.CreateOrUpdate(this.ResourceGroup, parameters).Offer;
     }
 }
 /// <summary>
 /// Your documentation here.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/XXXXX.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.AzureStack.Management.IManagedOfferOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. Your documentation here.
 /// </param>
 /// <param name='parameters'>
 /// Required. Your documentation here.
 /// </param>
 /// <returns>
 /// Your documentation here.
 /// </returns>
 public static Task<ManagedOfferCreateOrUpdateResult> CreateOrUpdateAsync(this IManagedOfferOperations operations, string resourceGroupName, ManagedOfferCreateOrUpdateParameters parameters)
 {
     return operations.CreateOrUpdateAsync(resourceGroupName, parameters, CancellationToken.None);
 }
示例#4
0
        /// <summary>
        /// Executes the API call(s) against Azure Resource Management API(s).
        /// </summary>
        protected override object ExecuteCore()
        {
            this.WriteVerbose(Resources.CreatingNewOffer.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,
                    }
                });

                var parameters = new ManagedOfferCreateOrUpdateParameters()
                {
                    Offer = new AdminOfferModel()
                    {
                        Name = this.Name,
                        Location = this.ArmLocation,
                        Properties = new AdminOfferDefinition()
                        {
                            Name = this.Name,
                            DisplayName = this.DisplayName,
                            State = this.State,
                        }
                    }
                };

                if (this.BasePlans != null && this.BasePlans.Length > 0)
                {
                    parameters.Offer.Properties.BasePlans = this.BasePlans.Select(plan => plan.Properties).ToArray();
                }

                if (client.ManagedOffers.List(this.ResourceGroup, includeDetails: false).Offers
                    .Any(offer => string.Equals(offer.Properties.Name, parameters.Offer.Properties.Name, StringComparison.OrdinalIgnoreCase)))
                {
                    throw new PSInvalidOperationException(Resources.ManagedOfferAlreadyExists.FormatArgs(parameters.Offer.Properties.Name, this.ResourceGroup));
                }

                return client.ManagedOffers.CreateOrUpdate(this.ResourceGroup, parameters).Offer;
            }
        }