public void TestCreateMachine()
 {
     AzureMachineAdapter azureMachineAdapter = null;
     OperationAdapter operationHelper = null;
     using (StreamReader reader = new StreamReader(new FileStream(@"D:\andyzone\WSEEverywhere2\AzureRestAdapter\data\Windows Azure MSDN - Visual Studio Ultimate-5-28-2013-credentials.publishsettings", FileMode.Open, FileAccess.Read)))
     {
         string publishSettings = reader.ReadToEnd();
         azureMachineAdapter = new AzureMachineAdapter(publishSettings);
         operationHelper = new OperationAdapter(publishSettings);
     }
     string label = "My example service";
     azureMachineAdapter.CreateMachine(serviceName, label, machineName, "aurorauser", "Quattro!", mediaLink, osDiskName);
 }
        public void TestNewAzureDisk()
        {
            AzureMachineAdapter azureMachineAdapter = null;
            OperationAdapter operationHelper = null;
            using (StreamReader reader = new StreamReader(new FileStream(@"D:\andyzone\WSEEverywhere2\AzureRestAdapter\data\Windows Azure MSDN - Visual Studio Ultimate-5-28-2013-credentials.publishsettings", FileMode.Open, FileAccess.Read)))
            {
                string publishSettings = reader.ReadToEnd();
                azureMachineAdapter = new AzureMachineAdapter(publishSettings);
                operationHelper = new OperationAdapter(publishSettings);
            }

            // Create the new storage account with the following values:
            string label = "andyliu os disk label";
            string diskName = "andyliuosdisk";
            string requestId = azureMachineAdapter.NewAzureDisk(diskName, label, mediaLink);

            Console.WriteLine(
                "Called Create Storage Account operation: requestId {0}",
                requestId);
        }
        public void TestCreateCloudService()
        {
            AzureMachineAdapter azureMachineAdapter = null;
            OperationAdapter operationHelper = null;
            using (StreamReader reader = new StreamReader(new FileStream(@"D:\andyzone\WSEEverywhere2\AzureRestAdapter\data\Windows Azure MSDN - Visual Studio Ultimate-5-28-2013-credentials.publishsettings", FileMode.Open, FileAccess.Read)))
            {
                string publishSettings = reader.ReadToEnd();
                azureMachineAdapter = new AzureMachineAdapter(publishSettings);
                operationHelper = new OperationAdapter(publishSettings);
            }

            // Create the new storage account with the following values:
            string label = "My example cloud service label";
            string location = "East Asia";

            string requestId = azureMachineAdapter.NewAzureCloudService(serviceName, location, label, null);

            Console.WriteLine(
                "Called Create Storage Account operation: requestId {0}",
                requestId);
        }
        public void TestCreateStorageAccount()
        {
            try
            {
                StorageAccountAdapter storageAccountAdapter = null;
                OperationAdapter operationHelper = null;
                using (StreamReader reader = new StreamReader(new FileStream(@"D:\andyzone\WSEEverywhere2\AzureRestAdapter\data\Windows Azure MSDN - Visual Studio Ultimate-5-28-2013-credentials.publishsettings", FileMode.Open, FileAccess.Read)))
                {
                    string publishSettings = reader.ReadToEnd();
                    storageAccountAdapter = new StorageAccountAdapter(publishSettings);
                    operationHelper = new OperationAdapter(publishSettings);
                }

                // Create the new storage account with the following values:
                string description = "Description for my example storage account";
                string label = "My example storage account label";
                string location = "East Asia";
                string ServiceName = storageAccountName;
                bool? enableGeoReplication = true;
                string requestId = storageAccountAdapter.CreateStorageAccount(
                    ServiceName,
                    description,
                    label,
                    null,
                    location,
                    enableGeoReplication);
                Console.WriteLine(
                    "Called Create Storage Account operation: requestId {0}",
                    requestId);

                // Loop on Get Operation Status for result of storage creation
                OperationResult result = operationHelper.PollGetOperationStatus(
                    requestId,
                    pollIntervalSeconds: 20,
                    timeoutSeconds: 600);
                switch (result.Status)
                {
                    case OperationStatus.TimedOut:
                        Console.WriteLine(
                            "Poll of Get Operation Status timed out: " +
                            "Operation {0} is still in progress after {1} seconds.",
                            requestId,
                            (int)result.RunningTime.TotalSeconds);
                        break;

                    case OperationStatus.Failed:
                        Console.WriteLine(
                            "Failed: Operation {0} failed after " +
                            "{1} seconds with status {2} ({3}) - {4}: {5}",
                            requestId,
                            (int)result.RunningTime.TotalSeconds,
                            (int)result.StatusCode,
                            result.StatusCode,
                            result.Code,
                            result.Message);
                        break;

                    case OperationStatus.Succeeded:
                        Console.WriteLine(
                            "Succeeded: Operation {0} completed " +
                            "after {1} seconds with status {2} ({3})",
                            requestId,
                            (int)result.RunningTime.TotalSeconds,
                            (int)result.StatusCode,
                            result.StatusCode);
                        break;
                }

                // Display the property values for the new storage account.
                // Convert the Label property to a readable value for display.
                XElement updatedProperties =
                    storageAccountAdapter.GetStorageAccountProperties(ServiceName);
                XElement labelElement = updatedProperties.Descendants(AzureRestAdapterConstants.NameSpaceWA + "Label").First();
                labelElement.Value = labelElement.Value.FromBase64();
                Console.WriteLine(
                    "New Storage Account Properties for {0}:{1}{2}",
                    ServiceName,
                    Environment.NewLine,
                    updatedProperties.ToString(SaveOptions.OmitDuplicateNamespaces));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception caught in Main:");
                Console.WriteLine(ex.Message);
            }
        }
 public void TestNewAzureVMImage()
 {
     AzureMachineAdapter azureMachineAdapter = null;
     OperationAdapter operationHelper = null;
     using (StreamReader reader = new StreamReader(new FileStream(@"D:\andyzone\WSEEverywhere2\AzureRestAdapter\data\Windows Azure MSDN - Visual Studio Ultimate-5-28-2013-credentials.publishsettings", FileMode.Open, FileAccess.Read)))
     {
         string publishSettings = reader.ReadToEnd();
         azureMachineAdapter = new AzureMachineAdapter(publishSettings);
         operationHelper = new OperationAdapter(publishSettings);
     }
     string label = "andy liu vm image label";
     string requestId = azureMachineAdapter.NewAzureVMImage(vmImageName, mediaLink, label);
 }