Example #1
0
        public void CreateAndDelete()
        {
            // Set name of new cloud service.
            var name = Guid.NewGuid().ToString();

            // Set location of new cloud service to first US location
            // found available in the current subscription.
            var    locationsApi = new Locations.LocationsApi(this.subscription);
            var    locations    = locationsApi.List();
            string location     = null;

            foreach (DataCenterLocation dcLocation in locations)
            {
                if (dcLocation.Name.EndsWith(" US"))
                {
                    location = dcLocation.Name;
                    break;
                }
            }
            Assert.IsFalse(string.IsNullOrEmpty(location));

            // Create a cloud service.
            Console.WriteLine("Creating cloud service '{0}' in data center '{1}'.",
                              name, location);
            var cloudServiceUri = this.cloudServicesApi.Create(name, location);

            Console.WriteLine("Cloud service created.");
            Console.WriteLine(cloudServiceUri);

            // Delete the same cloud service.
            this.cloudServicesApi.Delete(name);

            Console.WriteLine("Cloud service deleted.");
        }
        public void CreateAndDelete()
        {
            // Set name of new cloud service.
            var name = Guid.NewGuid().ToString();

            // Set location of new cloud service to first US location
            // found available in the current subscription.
            var locationsApi = new Locations.LocationsApi(this.subscription);
            var locations = locationsApi.List();
            string location = null;
            foreach (DataCenterLocation dcLocation in locations)
            {
                if (dcLocation.Name.EndsWith(" US"))
                {
                    location = dcLocation.Name;
                    break;
                }
            }
            Assert.IsFalse(string.IsNullOrEmpty(location));

            // Create a cloud service.
            Console.WriteLine("Creating cloud service '{0}' in data center '{1}'.",
                name, location);
            var cloudServiceUri = this.cloudServicesApi.Create(name, location);

            Console.WriteLine("Cloud service created.");
            Console.WriteLine(cloudServiceUri);

            // Delete the same cloud service.
            this.cloudServicesApi.Delete(name);

            Console.WriteLine("Cloud service deleted.");
        }