public ManagedDiskSetupServiceStandalone(
     IComputeManagementClient computeManagementClient,
     ILogger <ManagedDiskSetupServiceStandalone> logger)
 {
     this.computeManagementClient = computeManagementClient;
     this.logger = logger;
 }
Example #2
0
 public NetworkClient(INetworkManagementClient client, IComputeManagementClient computeClient, IManagementClient managementClient, ICommandRuntime commandRuntime)
 {
     this.client           = client;
     this.computeClient    = computeClient;
     this.managementClient = managementClient;
     this.commandRuntime   = commandRuntime;
 }
 public ManagedDiskProvisionService(
     IComputeManagementClient computeManagementClient,
     ILogger <ManagedDiskProvisionService> logger)
 {
     this.computeManagementClient = computeManagementClient;
     this.logger = logger;
 }
Example #4
0
 /// <summary>
 /// The Get Operation Status operation returns the status of the
 /// specified operation. After calling an asynchronous operation, you
 /// can call Get Operation Status to determine whether the operation
 /// has succeeded, failed, or is still in progress.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/ee460783.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Compute.IComputeManagementClient.
 /// </param>
 /// <param name='requestId'>
 /// Required. The request ID for the request you wish to track. The
 /// request ID is returned in the x-ms-request-id response header for
 /// every request.
 /// </param>
 /// <returns>
 /// The response body contains the status of the specified asynchronous
 /// operation, indicating whether it has succeeded, is inprogress, or
 /// has failed. Note that this status is distinct from the HTTP status
 /// code returned for the Get Operation Status operation itself. If
 /// the asynchronous operation succeeded, the response body includes
 /// the HTTP status code for the successful request. If the
 /// asynchronous operation failed, the response body includes the HTTP
 /// status code for the failed request and error information regarding
 /// the failure.
 /// </returns>
 public static OperationStatusResponse GetOperationStatus(this IComputeManagementClient operations, string requestId)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IComputeManagementClient)s).GetOperationStatusAsync(requestId);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
            public ComputeManagementClientShould()
            {
                var credManager = CredentialManager.FromServicePrincipalEnvVariable();

                Client = new ComputeManagementClient(credManager.TokenCredentials)
                {
                    SubscriptionId = credManager.SubscriptionId
                };
            }
Example #6
0
        private async Task <IComputeManagementClient> GetComputeManagementAsync()
        {
            if (_compute != null)
            {
                return(_compute);
            }
            var token = await _servicePrincipalAuthentication.AquireTokenAsync();

            _compute = new ComputeManagementClient(new TokenCloudCredentials(Configuration.SubscriptionId, token));
            return(_compute);
        }
        /// <summary>
        /// Get an instance of the Dedicated Host compute client.
        /// </summary>
        /// <param name="subscriptionId">Subscription ID.</param>
        /// <param name="azureCredentials">Credentials used for Azure authentication.</param>
        /// <param name="azureEnvironment">Azure cloud.</param>

        public async Task <IComputeManagementClient> GetComputeManagementClient(
            string subscriptionId,
            AzureCredentials azureCredentials,
            AzureEnvironment azureEnvironment)
        {
            var baseUri = await GetResourceManagerEndpoint(azureEnvironment);

            return(_computeManagementClient ?? (_computeManagementClient = new ComputeManagementClient(azureCredentials)
            {
                SubscriptionId = subscriptionId,
                BaseUri = baseUri,
                LongRunningOperationRetryTimeout = _config.ComputeClientLongRunningOperationRetryTimeoutSeconds,
                HttpClient = { Timeout = TimeSpan.FromMinutes(_config.ComputeClientHttpTimeoutMin) }
            }));
        }
 /// <summary>
 /// The Get Operation Status operation returns the status of
 /// thespecified operation. After calling an asynchronous operation,
 /// you can call Get Operation Status to determine whether the
 /// operation has succeeded, failed, or is still in progress.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/ee460783.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Compute.IComputeManagementClient.
 /// </param>
 /// <param name='requestId'>
 /// The request ID for the request you wish to track. The request ID is
 /// returned in the x-ms-request-id response header for every request.
 /// </param>
 /// <returns>
 /// The response body contains the status of the specified asynchronous
 /// operation, indicating whether it has succeeded, is inprogress, or
 /// has failed. Note that this status is distinct from the HTTP status
 /// code returned for the Get Operation Status operation itself.  If
 /// the asynchronous operation succeeded, the response body includes
 /// the HTTP status code for the successful request.  If the
 /// asynchronous operation failed, the response body includes the HTTP
 /// status code for the failed request, and also includes error
 /// information regarding the failure.
 /// </returns>
 public static ComputeOperationStatusResponse GetOperationStatus(this IComputeManagementClient operations, string requestId)
 {
     try
     {
         return(operations.GetOperationStatusAsync(requestId).Result);
     }
     catch (AggregateException ex)
     {
         if (ex.InnerExceptions.Count > 1)
         {
             throw;
         }
         else
         {
             throw ex.InnerException;
         }
     }
 }
 internal AzureCloudServiceManager(IWebRequestor requestor)
 {
     _webRequestor = requestor;
     ComputeManagementClient = new ComputeManagementClient(Dependencies.Subscription.Credentials);
 }
 public VirtualMachineExtensionImageFactory(IComputeManagementClient computeClient)
 {
     this.computeClient = computeClient;
 }
Example #11
0
 public ComputeClient(IComputeManagementClient computeManagementClient)
 {
     ComputeManagementClient = computeManagementClient;
 }
 public VirtualMachineExtensionImageFactory(IComputeManagementClient computeClient)
 {
     this.computeClient = computeClient;
 }
        public static VirtualMachine CreateVirtualMachine(
            IComputeManagementClient computeManagementClient,
            IAzure azure,
            Region region,
            string resourceGroupName,
            string vmName,
            string vmSize,
            string availabilityZone,
            string pipName,
            string vnetName,
            string nicName)
        {
            if (computeManagementClient == null)
            {
                throw new ArgumentNullException(nameof(computeManagementClient));
            }

            if (azure == null)
            {
                throw new ArgumentNullException(nameof(azure));
            }

            if (region == null)
            {
                throw new ArgumentNullException(nameof(region));
            }

            if (string.IsNullOrEmpty(resourceGroupName))
            {
                throw new ArgumentException(nameof(resourceGroupName));
            }

            if (string.IsNullOrEmpty(vmName))
            {
                throw new ArgumentException(nameof(vmName));
            }

            if (string.IsNullOrEmpty(vmSize))
            {
                throw new ArgumentException(nameof(vmSize));
            }

            if (string.IsNullOrEmpty(pipName))
            {
                throw new ArgumentException(nameof(pipName));
            }

            if (string.IsNullOrEmpty(vnetName))
            {
                throw new ArgumentException(nameof(vnetName));
            }

            if (string.IsNullOrEmpty(nicName))
            {
                throw new ArgumentException(nameof(nicName));
            }

            Console.WriteLine($"Creating resource group {resourceGroupName}");
            var resourceGroup = azure.ResourceGroups.Define(resourceGroupName)
                                .WithRegion(region)
                                .Create();

            Console.WriteLine($"Creating public IP address {pipName}");
            var publicIpAddress = azure.PublicIPAddresses.Define(pipName)
                                  .WithRegion(region)
                                  .WithExistingResourceGroup(resourceGroupName)
                                  .WithDynamicIP()
                                  .Create();

            Console.WriteLine($"Creating virtual network {vnetName}");
            var network = azure.Networks.Define(vnetName)
                          .WithRegion(region)
                          .WithExistingResourceGroup(resourceGroupName)
                          .WithAddressSpace("10.0.0.0/16")
                          .WithSubnet("adhSubnet", "10.0.0.0/24")
                          .Create();

            Console.WriteLine($"Creating network interface {nicName}");
            var networkInterface = azure.NetworkInterfaces.Define(nicName)
                                   .WithRegion(region)
                                   .WithExistingResourceGroup(resourceGroupName)
                                   .WithExistingPrimaryNetwork(network)
                                   .WithSubnet("adhSubnet")
                                   .WithPrimaryPrivateIPAddressDynamic()
                                   .WithExistingPrimaryPublicIPAddress(publicIpAddress)
                                   .Create();

            Console.WriteLine($"Configuring virtual machine {vmName}" + Environment.NewLine);
            var imageRef = new ImageReference
            {
                Publisher = "MicrosoftWindowsServer",
                Sku       = "2012-R2-Datacenter",
                Offer     = "WindowsServer",
                Version   = "latest"
            };

            return(new VirtualMachine(
                       region.Name,
                       Guid.NewGuid().ToString(),
                       vmName,
                       "",
                       null,
                       null,
                       new Microsoft.Azure.Management.Compute.Models.HardwareProfile {
                VmSize = vmSize
            },
                       new Microsoft.Azure.Management.Compute.Models.StorageProfile
            {
                ImageReference = imageRef,
                OsDisk = new Microsoft.Azure.Management.Compute.Models.OSDisk
                {
                    Caching = CachingTypes.None,
                    CreateOption = DiskCreateOptionTypes.FromImage,
                    Name = "disk-" + Guid.NewGuid(),
                    Vhd = null,
                    ManagedDisk = new ManagedDiskParameters
                    {
                        StorageAccountType = "Standard_LRS"
                    }
                },
            },
                       null,
                       new Microsoft.Azure.Management.Compute.Models.OSProfile
            {
                AdminUsername = "******",
                AdminPassword = Guid.NewGuid().ToString(),
                ComputerName = vmName,
            },
                       new Microsoft.Azure.Management.Compute.Models.NetworkProfile
            {
                NetworkInterfaces = new List <NetworkInterfaceReference>
                {
                    new NetworkInterfaceReference(networkInterface.Id)
                }
            },
                       null,
                       null,
                       null,
                       null,
                       null,
                       null,
                       null,
                       null,
                       null,
                       null,
                       null,
                       null,
                       null,
                       null,
                       null));
        }
 public ComputeClient(IComputeManagementClient resourceManagementClient)
 {
     ComputeManagementClient = resourceManagementClient;
 }
Example #15
0
 internal AzureCloudServiceManager(IWebRequestor requestor)
 {
     _webRequestor           = requestor;
     ComputeManagementClient = new ComputeManagementClient(Dependencies.Subscription.Credentials);
 }
 internal AzureVirtualMachineManager()
 {
     ComputeManagementClient = new ComputeManagementClient(Dependencies.Subscription.Credentials,
                                                           new Uri(Dependencies.Subscription.CoreEndpointUrl));
 }
 internal AzureVirtualMachineManager()
 {
     ComputeManagementClient = new ComputeManagementClient(Dependencies.Subscription.Credentials,
         new Uri(Dependencies.Subscription.CoreEndpointUrl));
 }
Example #18
0
 ///GENMHASH:38AF54D6D93CDEF7138D771AB45B7132:FCBE9313644315745EDD2396965C2FE2
 internal ComputeUsagesImpl(IComputeManagementClient client)
 {
     this.client = client;
 }
 public ManagedDiskSetupServiceVmss(IComputeManagementClient computeManagementClient,
                                    ILogger <ManagedDiskSetupServiceVmss> logger)
 {
     this.computeManagementClient = computeManagementClient;
     this.logger = logger;
 }
Example #20
0
 public ComputeClient(IComputeManagementClient resourceManagementClient)
 {
     ComputeManagementClient = resourceManagementClient;
 }
Example #21
0
 /// <summary>
 /// The Get Operation Status operation returns the status of the
 /// specified operation. After calling an asynchronous operation, you
 /// can call Get Operation Status to determine whether the operation
 /// has succeeded, failed, or is still in progress.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/ee460783.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Compute.IComputeManagementClient.
 /// </param>
 /// <param name='requestId'>
 /// Required. The request ID for the request you wish to track. The
 /// request ID is returned in the x-ms-request-id response header for
 /// every request.
 /// </param>
 /// <returns>
 /// The response body contains the status of the specified asynchronous
 /// operation, indicating whether it has succeeded, is inprogress, or
 /// has failed. Note that this status is distinct from the HTTP status
 /// code returned for the Get Operation Status operation itself. If
 /// the asynchronous operation succeeded, the response body includes
 /// the HTTP status code for the successful request. If the
 /// asynchronous operation failed, the response body includes the HTTP
 /// status code for the failed request and error information regarding
 /// the failure.
 /// </returns>
 public static Task <OperationStatusResponse> GetOperationStatusAsync(this IComputeManagementClient operations, string requestId)
 {
     return(operations.GetOperationStatusAsync(requestId, CancellationToken.None));
 }
 /// <summary>
 /// The Get Delete Operation Status operation returns the status of the
 /// specified operation. After calling an asynchronous operation, you
 /// can call GetDeleteOperationStatus to determine whether the
 /// operation has succeeded, failed, or is still in progress.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.Compute.IComputeManagementClient.
 /// </param>
 /// <param name='operationStatusLink'>
 /// Required. Location value returned by the Begin operation.
 /// </param>
 /// <returns>
 /// The compute long running operation response.
 /// </returns>
 public static Task <DeleteOperationResponse> GetDeleteOperationStatusAsync(this IComputeManagementClient operations, string operationStatusLink)
 {
     return(operations.GetDeleteOperationStatusAsync(operationStatusLink, CancellationToken.None));
 }
 private async Task<IComputeManagementClient> GetComputeManagementAsync()
 {
     if (_compute != null)
     {
         return _compute;
     }
     var token = await _servicePrincipalAuthentication.AquireTokenAsync();
     _compute = new ComputeManagementClient(new TokenCloudCredentials(Configuration.SubscriptionId, token));
     return _compute;
 }
 public ComputeClient(IComputeManagementClient computeManagementClient)
 {
     ComputeManagementClient = computeManagementClient;
 }