public SchedulerManagementClient CreateClient()
 {
     _credentialManager.Initialise();
     var credentials = _credentialManager.GetManagementCredentials();
     CreateCloudService(credentials,Config.cloudServiceName);
     var schedulerServiceClient = new SchedulerManagementClient(credentials);
     schedulerServiceClient.RegisterResourceProvider();
     return schedulerServiceClient;
 }
예제 #2
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                throw new ArgumentNullException("publish settings informations");
            }
            SubscriptionCloudCredentials cred = GetCredentials(args[0]);

            //WATM
            TrafficManagerManagementClient watmClient = new TrafficManagerManagementClient(cred);
            string atmDns = "adxsdk12345.trafficmanager.net";
            DnsPrefixAvailabilityCheckResponse watmResp = 
                watmClient.Profiles.CheckDnsPrefixAvailability("adxsdk12345.trafficmanager.net");
            Console.WriteLine("Invoke WATM->CheckDnsPrefixAvailability(\'{0}\'). Result: {1}", atmDns, watmResp.Result);

            //Compute
            ComputeManagementClient computeClient = new ComputeManagementClient(cred);
            string hostServiceName = "adxsdk12345";
            HostedServiceCheckNameAvailabilityResponse computeResp = 
                computeClient.HostedServices.CheckNameAvailability(hostServiceName);
            Console.WriteLine("Invoke Compute->CheckNameAvailability(\'{0}\'). Result: {1}", 
                hostServiceName, computeResp.IsAvailable);

            //Websites
            WebSiteManagementClient websiteClient = new WebSiteManagementClient(cred);
            string webSiteName = "adxsdk12345";
            WebSiteIsHostnameAvailableResponse webSiteResp = websiteClient.WebSites.IsHostnameAvailable(webSiteName);
            Console.WriteLine("Invoke WebSite->IsHostnameAvailable(\'{0}\'). Result: {1}", 
                webSiteName, webSiteResp.IsAvailable);

            //Scheduler
            SchedulerManagementClient schedulerClient = new SchedulerManagementClient(cred);
            string schedulerCloudServiceName = "foobarrr";
            string expectedSchedulerException = string.Format(
                "ResourceNotFound: The cloud service with name {0} was not found.", schedulerCloudServiceName);
            bool exceptionFromSchedulerServiceOccurred = false;
            try
            {
                schedulerClient.JobCollections.CheckNameAvailability(schedulerCloudServiceName, "doesnotmatter");
            }
            catch (Exception ex)
            {
                if (ex.Message == expectedSchedulerException)
                {
                    exceptionFromSchedulerServiceOccurred = true;
                    Console.WriteLine("Invoke Scheduler->CheckNameAvailability(\'{0}\'). Get back correct exception", 
                        schedulerCloudServiceName, expectedSchedulerException);
                }
            }
            if (!exceptionFromSchedulerServiceOccurred)
            {
                throw new Exception("we didn't get expected exception message from scheduler service");
            }

            Console.WriteLine("Smoke test is good");
        }
예제 #3
0
        protected override void Clone(ServiceClient <SchedulerManagementClient> client)
        {
            base.Clone(client);
            SchedulerManagementClient management = client as SchedulerManagementClient;

            if (management != null)
            {
                management._credentials = Credentials;
                management._baseUri     = BaseUri;
                management.Credentials.InitializeServiceClient(management);
            }
        }
        public Program(ScheduledWebJobCreatorParameters parms)
        {
            // auth
            _credential = TokenCredentialHelper<MyPersonalConfiguration>.GetCredentials(
                new MyPersonalConfiguration(parms),
                parms.subscriptionId);

            // create the clients needed
            _cloudServiceManagementClient = CloudContext.Clients.CreateCloudServiceManagementClient(_credential);
            _webSiteMgmtClient = CloudContext.Clients.CreateWebSiteManagementClient(_credential);
            _schedulerMgmtClient = CloudContext.Clients.CreateSchedulerManagementClient(_credential);
        }
예제 #5
0
 public SchedulerOperationStatusResponse CreateJobCollection(SchedulerManagementClient schedulerServiceClient, string jobCollectionName)
 {
     var result = schedulerServiceClient.JobCollections.Create(cloudSerivceName, jobCollectionName, new JobCollectionCreateParameters()
     {
         Label = jobCollectionName,
         IntrinsicSettings = new JobCollectionIntrinsicSettings()
         {
             Plan = JobCollectionPlan.Standard,
             Quota = new JobCollectionQuota()
             {
                 MaxJobCount = 100,
                 MaxJobOccurrence = 100,
                 MaxRecurrence = new JobCollectionMaxRecurrence()
                 {
                     Frequency = JobCollectionRecurrenceFrequency.Minute,
                     Interval = 1
                 }
             }
         }
     });
     return result;
 }
        /// <summary>
        /// Creates new Scheduler Management Convenience Client
        /// </summary>
        /// <param name="subscription">Subscription containing websites to manipulate</param>
        public SchedulerMgmntClient(AzureSubscription subscription)
        {
            currentSubscription = subscription;
            csmClient = AzureSession.ClientFactory.CreateClient<CloudServiceManagementClient>(subscription, AzureEnvironment.Endpoint.ServiceManagement);
            schedulerManagementClient = AzureSession.ClientFactory.CreateClient<SchedulerManagementClient>(subscription, AzureEnvironment.Endpoint.ServiceManagement);

            //Get RP properties
            IDictionary<string, string> dict = schedulerManagementClient.GetResourceProviderProperties().Properties;

            //Get available regions
            string val = string.Empty;
            if (dict.TryGetValue(SupportedRegionsKey, out val))
            {
                AvailableRegions = new List<string>();
                val.Split(',').ToList().ForEach(s => AvailableRegions.Add(s));
            }

            //Store global counts for max jobs and min recurrence for each plan     
            if (dict.TryGetValue(FreeMaxJobCountKey, out val))
                FreeMaxJobCountValue = Convert.ToInt32(dict[FreeMaxJobCountKey]);

            if (dict.TryGetValue(FreeMinRecurrenceKey, out val))
                FreeMinRecurrenceValue = TimeSpan.Parse(dict[FreeMinRecurrenceKey]);

            if (dict.TryGetValue(StandardMaxJobCountKey, out val))
                StandardMaxJobCountValue = Convert.ToInt32(dict[StandardMaxJobCountKey]);

            if (dict.TryGetValue(StandardMinRecurrenceKey, out val))
                StandardMinRecurrenceValue = TimeSpan.Parse(dict[StandardMinRecurrenceKey]);

            if (dict.TryGetValue(PremiumMaxJobCountKey, out val))
                PremiumMaxJobCountValue = Convert.ToInt32(dict[PremiumMaxJobCountKey]);

            if (dict.TryGetValue(PremiumMinRecurrenceKey, out val))
                PremiumMinRecurrenceValue = TimeSpan.Parse(dict[PremiumMinRecurrenceKey]);
        }
 /// <summary>
 /// Creates new Scheduler Management Convenience Client
 /// </summary>
 /// <param name="subscription">Subscription containing websites to manipulate</param>
 public SchedulerMgmntClient(WindowsAzureSubscription subscription)
 {
     csmClient = subscription.CreateClient<CloudServiceManagementClient>();
     schedulerManagementClient = subscription.CreateClient<SchedulerManagementClient>();
 }