Ejemplo n.º 1
0
        protected void SetupManagementClients(MockContext context)
        {
            ResourceManagementClient = GetResourceManagementClient(context);
            BillingManagementClient  = GetBillingManagementClient(context);

            _helper.SetupManagementClients(
                ResourceManagementClient,
                BillingManagementClient);
        }
        static void Main(string[] args)
        {
            var armCreds   = GetCreds();
            var billClient = new BillingManagementClient(armCreds);

            Write("Listing some enrollment accounts ...");
            var enrollmentAccounts = billClient.EnrollmentAccounts.List().Value;

            Write("{0} enrollment account(s) found.  Press ENTER to see them.", enrollmentAccounts.Count);
            Console.ReadLine();

            EnrollmentAccount chosenAccount = new EnrollmentAccount();

            foreach (var enrollmentAccount in enrollmentAccounts)
            {
                Write("\tName: {0}", enrollmentAccount.PrincipalName);
                Write("\tEnrollment account ID: {0}", enrollmentAccount.Name);
                ConsoleKey response;
                do
                {
                    Write("Use this enrollment account to create subscriptions? [y/n] ");
                    response = Console.ReadKey(false).Key;
                    if (response != ConsoleKey.Enter)
                    {
                        Write(Environment.NewLine);
                    }
                } while (response != ConsoleKey.Y && response != ConsoleKey.N);

                if (response == ConsoleKey.Y)
                {
                    chosenAccount = enrollmentAccount;
                }
            }
            ;

            var subClient = new SubscriptionClient(armCreds);

            Write("Press ENTER to create a subscription");
            Console.ReadLine();

            Write("Creating a new subscription, please wait...");

            var subscriptionParams = new SubscriptionCreationParameters()
            {
                DisplayName = "My New Programmatically Created Subscription",
                OfferType   = "MS-AZR-0017P",
                Owners      = null
            };

            var newSub = subClient.SubscriptionFactory.CreateSubscriptionInEnrollmentAccount(chosenAccount.Name, subscriptionParams);

            Write("\tSubId: {0}", newSub.SubscriptionLink);
            Console.ReadLine();
        }