public static Pageable <ArmResource> ListVirtualMachinesByName(this SubscriptionOperations subscription, ArmSubstringFilter filter, int?top = null, CancellationToken cancellationToken = default) { ArmFilterCollection filters = new ArmFilterCollection(VirtualMachineOperations.ResourceType); filters.SubstringFilter = filter; return(ResourceListOperations.ListAtContext(subscription.ClientOptions, subscription.Id, filters, top, cancellationToken)); }
/// <summary> /// Reverts the subscription renewal. /// </summary> /// <returns>A task.</returns> public async Task RollbackAsync() { if (Result != null) { try { // restore the original subscription state await SubscriptionOperations.PatchAsync(existingSubscription).ConfigureAwait(false); } catch (Exception rollbackProblem) { if (rollbackProblem.IsFatal()) { throw; } Trace.TraceError( "RenewSubscription.RollbackAsync failed: {0}, Customer ID: {1}, Subscription ID: {2}, Subscription: {3}", rollbackProblem, SubscriptionOperations.Context.Item1, SubscriptionOperations.Context.Item2, existingSubscription); // TODO: Notify the system integrity recovery component } } Result = null; }
/// <summary> /// Reverts the seat change. /// </summary> /// <returns>A task.</returns> public async Task RollbackAsync() { if (Result != null) { try { // restore the original seat count for the subscription Result.Quantity = originalSeatCount; await SubscriptionOperations.PatchAsync(Result).ConfigureAwait(false); } catch (Exception subscriptionUpdateProblem) { if (subscriptionUpdateProblem.IsFatal()) { throw; } Trace.TraceError("PurchaseExtraSeats.RollbackAsync failed: {0}, ID: {1}, Quantity: {2}.", subscriptionUpdateProblem, this.Result.Id, this.Result.Quantity); // TODO: Notify the system integrity recovery component } } this.Result = null; }
/// <summary> /// Purchases additional seats for the subscription. /// </summary> /// <returns>A task.</returns> public async Task ExecuteAsync() { try { // activate the subscription (in case it was suspended) Result = await SubscriptionOperations.PatchAsync(new Subscription() { Status = SubscriptionStatus.Active }).ConfigureAwait(false); } catch (PartnerException subscriptionUpdateProblem) { string exceptionMessage = string.Format( CultureInfo.InvariantCulture, Resources.RenewSubscriptionFailedMessage, subscriptionUpdateProblem, existingSubscription.Id); if (subscriptionUpdateProblem.ErrorCategory == PartnerErrorCategory.NotFound) { throw new PartnerDomainException(ErrorCode.SubscriptionNotFound, exceptionMessage, subscriptionUpdateProblem); } else { throw new PartnerDomainException(ErrorCode.SubscriptionUpdateFailure, exceptionMessage, subscriptionUpdateProblem); } } }
/// <summary> /// Filters the list of VMs for a SubscriptionOperations represented as generic resources. /// </summary> /// <param name="subscription"> The <see cref="SubscriptionOperations" /> instance the method will execute against. </param> /// <param name="filter"> The string to filter the list. </param> /// <param name="top"> The number of results to return. </param> /// <param name="cancellationToken"> A token to allow the caller to cancel the call to the service. The default value is <see cref="P:System.Threading.CancellationToken.None" />. </param> /// <returns> An async collection of resource operations that may take multiple service requests to iterate over. </returns> public static AsyncPageable <GenericResource> ListVirtualMachinesByNameAsync(this SubscriptionOperations subscription, string filter, int?top = null, CancellationToken cancellationToken = default) { ResourceFilterCollection filters = new ResourceFilterCollection(VirtualMachineOperations.ResourceType); filters.SubstringFilter = filter; return(ResourceListOperations.ListAtContextAsync(subscription, filters, top, cancellationToken)); }
private static NetworkManagementClient GetNetworkClient(SubscriptionOperations subscription) { return(new NetworkManagementClient( subscription.Id.Subscription, subscription.BaseUri, subscription.Credential, subscription.ClientOptions.Convert <NetworkManagementClientOptions>())); }
private static ComputeManagementClient GetComputeClient(SubscriptionOperations subscription) { return(new ComputeManagementClient( subscription.BaseUri, subscription.Id.Subscription, subscription.Credential, subscription.ClientOptions.Convert <ComputeManagementClientOptions>())); }
/// <summary> /// Lists the VirtualMachines for this SubscriptionOperations. /// </summary> /// <param name="subscription"> The <see cref="SubscriptionOperations" /> instance the method will execute against. </param> /// <returns> An async collection of resource operations that may take multiple service requests to iterate over. </returns> public static AsyncPageable <VirtualMachine> ListVirtualMachinesAsync(this SubscriptionOperations subscription) { var vmOperations = GetComputeClient(subscription).VirtualMachines; var result = vmOperations.ListAllAsync(); return(new PhWrappingAsyncPageable <Azure.ResourceManager.Compute.Models.VirtualMachine, VirtualMachine>( result, s => new VirtualMachine(subscription, new VirtualMachineData(s)))); }
/// <summary> /// Lists the <see cref="NetworkInterface"/> for this <see cref="Subscription"/>. /// </summary> /// <param name="subscription"> The <see cref="Subscription"/> to target for listing. </param> /// <returns> An async collection of resource operations that may take multiple service requests to iterate over. </returns> public static AsyncPageable <NetworkInterface> ListNicsAsync(this SubscriptionOperations subscription) { NetworkManagementClient networkClient = GetNetworkClient(subscription); var networkInterfacesOperations = networkClient.NetworkInterfaces; var result = networkInterfacesOperations.ListAllAsync(); return(new PhWrappingAsyncPageable <Azure.ResourceManager.Network.Models.NetworkInterface, NetworkInterface>( result, s => new NetworkInterface(subscription, new NetworkInterfaceData(s)))); }
/// <summary> /// List vms at the given subscription context /// </summary> /// <param name="subscription"></param> /// <returns></returns> public static Pageable <VirtualMachine> ListVirtualMachines(this SubscriptionOperations subscription) { ComputeManagementClient computeClient = GetComputeClient(subscription); var vmOperations = computeClient.VirtualMachines; var result = vmOperations.ListAll(); return(new PhWrappingPageable <Azure.ResourceManager.Compute.Models.VirtualMachine, VirtualMachine>( result, s => new VirtualMachine(subscription.ClientOptions, new VirtualMachineData(s)))); }
/// <summary> /// Lists the public IP addresses for this subscription. /// </summary> /// <param name="subscription"> The <see cref="SubscriptionOperations" /> instance the method will execute against. </param> /// <returns> An async collection of <see cref="PublicIpAddress" /> resource operations that may take multiple service requests to iterate over. </returns> public static AsyncPageable <PublicIpAddress> ListPublicIpsAsync(this SubscriptionOperations subscription) { NetworkManagementClient networkClient = GetNetworkClient(subscription); var publicIPAddressesOperations = networkClient.PublicIPAddresses; var result = publicIPAddressesOperations.ListAllAsync(); return(new PhWrappingAsyncPageable <Azure.ResourceManager.Network.Models.PublicIPAddress, PublicIpAddress>( result, s => new PublicIpAddress(subscription, new PublicIPAddressData(s)))); }
/// <summary> /// Lists the virtual networks for this subscription. /// </summary> /// <param name="subscription"> The <see cref="SubscriptionOperations" /> instance the method will execute against. </param> /// <returns> An async collection of <see cref="VirtualNetwork" /> resource operations that may take multiple service requests to iterate over. </returns> public static AsyncPageable <VirtualNetwork> ListVnetsAsync(this SubscriptionOperations subscription) { NetworkManagementClient networkClient = GetNetworkClient(subscription); var vmOperations = networkClient.VirtualNetworks; var result = vmOperations.ListAllAsync(); return(new PhWrappingAsyncPageable <Azure.ResourceManager.Network.Models.VirtualNetwork, VirtualNetwork>( result, s => new VirtualNetwork(subscription, new VirtualNetworkData(s)))); }
/// <summary> /// Lists the network security groups for this subscription. /// </summary> /// <param name="subscription"> The <see cref="SubscriptionOperations" /> instance the method will execute against. </param> /// <returns> An async collection of <see cref="NetworkSecurityGroup" /> resource operations that may take multiple service requests to iterate over. </returns> public static AsyncPageable <NetworkSecurityGroup> ListNsgsAsync(this SubscriptionOperations subscription) { NetworkManagementClient networkClient = GetNetworkClient(subscription); var networkSecurityGroupsOperations = networkClient.NetworkSecurityGroups; var result = networkSecurityGroupsOperations.ListAllAsync(); return(new PhWrappingAsyncPageable <Azure.ResourceManager.Network.Models.NetworkSecurityGroup, NetworkSecurityGroup>( result, s => new NetworkSecurityGroup(subscription, new NetworkSecurityGroupData(s)))); }
/// <summary> /// /// </summary> /// <param name="subscription"></param> /// <returns></returns> public static AsyncPageable <VirtualMachine> ListVirtualMachinesAsync(this SubscriptionOperations subscription) { var vmOperations = subscription.GetClient((baseUri, cred) => new ComputeManagementClient(baseUri, subscription.Id.Subscription, cred, subscription.ClientOptions.Convert <ComputeManagementClientOptions>())).VirtualMachines; var result = vmOperations.ListAllAsync(); return(new PhWrappingAsyncPageable <Azure.ResourceManager.Compute.Models.VirtualMachine, VirtualMachine>( result, s => new VirtualMachine(subscription.ClientOptions, new VirtualMachineData(s)))); }
/// <summary> /// Lists the AvailabilitySets for this SubscriptionOperations. /// </summary> /// <param name="subscription"> The <see cref="SubscriptionOperations" /> instance the method will execute against. </param> /// <returns> A collection of resource operations that may take multiple service requests to iterate over. </returns> public static Pageable <AvailabilitySet> ListAvailabilitySets(this SubscriptionOperations subscription) { ComputeManagementClient computeClient = GetComputeClient(subscription); var availabilitySetOperations = computeClient.AvailabilitySets; var result = availabilitySetOperations.ListBySubscription(); return(new PhWrappingPageable <Azure.ResourceManager.Compute.Models.AvailabilitySet, AvailabilitySet>( result, s => new AvailabilitySet(subscription, new AvailabilitySetData(s)))); }
private static NetworkManagementClient GetNetworkClient(SubscriptionOperations subscription) { Func <Uri, TokenCredential, NetworkManagementClient> ctor = (baseUri, cred) => new NetworkManagementClient( subscription.Id.Subscription, baseUri, cred, subscription.ClientOptions.Convert <NetworkManagementClientOptions>()); var networkClient = subscription.GetClient(ctor); return(networkClient); }
private static ComputeManagementClient GetComputeClient(SubscriptionOperations subscription) { Func <Uri, TokenCredential, ComputeManagementClient> ctor = (baseUri, cred) => new ComputeManagementClient( baseUri, subscription.Id.Subscription, cred, subscription.ClientOptions.Convert <ComputeManagementClientOptions>()); var computeClient = subscription.GetClient(ctor); return(computeClient); }
/// <summary> /// Purchases additional seats for the subscription. /// </summary> /// <returns>A task.</returns> public async Task ExecuteAsync() { try { Subscription partnerCenterSubscription = await SubscriptionOperations.GetAsync().ConfigureAwait(false); originalSeatCount = partnerCenterSubscription.Quantity; partnerCenterSubscription.Quantity += SeatsToPurchase; Result = await SubscriptionOperations.PatchAsync(partnerCenterSubscription).ConfigureAwait(false); } catch (PartnerException subscriptionUpdateProblem) { if (subscriptionUpdateProblem.ErrorCategory == PartnerErrorCategory.NotFound) { throw new PartnerDomainException(ErrorCode.SubscriptionNotFound, "PurchaseExtraSeats.ExecuteAsync() Failed", subscriptionUpdateProblem); } else { throw new PartnerDomainException(ErrorCode.SubscriptionUpdateFailure, "PurchaseExtraSeats.ExecuteAsync() Failed", subscriptionUpdateProblem); } } }
/// <summary> /// Initializes client properties. /// </summary> private void Initialize() { Policy = new PolicyOperations(this); PolicySnippets = new PolicySnippetsOperations(this); Regions = new RegionsOperations(this); Api = new ApiOperations(this); ApiRevisions = new ApiRevisionsOperations(this); ApiRelease = new ApiReleaseOperations(this); ApiOperation = new ApiOperationOperations(this); ApiOperationPolicy = new ApiOperationPolicyOperations(this); ApiProduct = new ApiProductOperations(this); ApiPolicy = new ApiPolicyOperations(this); ApiSchema = new ApiSchemaOperations(this); ApiDiagnostic = new ApiDiagnosticOperations(this); ApiDiagnosticLogger = new ApiDiagnosticLoggerOperations(this); ApiIssue = new ApiIssueOperations(this); ApiIssueComment = new ApiIssueCommentOperations(this); ApiIssueAttachment = new ApiIssueAttachmentOperations(this); AuthorizationServer = new AuthorizationServerOperations(this); Backend = new BackendOperations(this); Certificate = new CertificateOperations(this); ApiManagementOperations = new ApiManagementOperations(this); ApiManagementServiceSkus = new ApiManagementServiceSkusOperations(this); ApiManagementService = new ApiManagementServiceOperations(this); Diagnostic = new DiagnosticOperations(this); DiagnosticLogger = new DiagnosticLoggerOperations(this); EmailTemplate = new EmailTemplateOperations(this); Group = new GroupOperations(this); GroupUser = new GroupUserOperations(this); IdentityProvider = new IdentityProviderOperations(this); Logger = new LoggerOperations(this); Notification = new NotificationOperations(this); NotificationRecipientUser = new NotificationRecipientUserOperations(this); NotificationRecipientEmail = new NotificationRecipientEmailOperations(this); NetworkStatus = new NetworkStatusOperations(this); OpenIdConnectProvider = new OpenIdConnectProviderOperations(this); SignInSettings = new SignInSettingsOperations(this); SignUpSettings = new SignUpSettingsOperations(this); DelegationSettings = new DelegationSettingsOperations(this); Product = new ProductOperations(this); ProductApi = new ProductApiOperations(this); ProductGroup = new ProductGroupOperations(this); ProductSubscriptions = new ProductSubscriptionsOperations(this); ProductPolicy = new ProductPolicyOperations(this); Property = new PropertyOperations(this); QuotaByCounterKeys = new QuotaByCounterKeysOperations(this); QuotaByPeriodKeys = new QuotaByPeriodKeysOperations(this); Reports = new ReportsOperations(this); Subscription = new SubscriptionOperations(this); TagResource = new TagResourceOperations(this); Tag = new TagOperations(this); TagDescription = new TagDescriptionOperations(this); Operation = new OperationOperations(this); TenantAccess = new TenantAccessOperations(this); TenantAccessGit = new TenantAccessGitOperations(this); TenantConfiguration = new TenantConfigurationOperations(this); User = new UserOperations(this); UserGroup = new UserGroupOperations(this); UserSubscription = new UserSubscriptionOperations(this); UserIdentities = new UserIdentitiesOperations(this); ApiVersionSet = new ApiVersionSetOperations(this); ApiExport = new ApiExportOperations(this); BaseUri = new System.Uri("https://management.azure.com"); ApiVersion = "2018-01-01"; AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; SerializationSettings = new JsonSerializerSettings { Formatting = Newtonsoft.Json.Formatting.Indented, DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; SerializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings = new JsonSerializerSettings { DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; CustomInitialize(); DeserializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); }
/// <summary> /// Get RoleAssignment Container for the given resource and scope. Note that this is only valid for unconstrained role assignments, so /// it is a generation-time decision if we include this. /// </summary> /// <param name="subscription">The subscription containign the role assignment</param> /// <param name="scope">The target of the role assignment</param> /// <returns>A <see cref="RoleAssignmentContainer"/> that allows creating and listing RoleAssignments</returns> public static RoleAssignmentContainer GetRoleAssigmentContainerAtScope(this SubscriptionOperations subscription, ResourceIdentifier scope) { return(new RoleAssignmentContainer(subscription, scope)); }
/// <summary> /// Get RoleAssignment Operations for the given resource and scope. Note that this is only valid for unconstrained role assignments, so /// it is a generation-time decision if we include this. /// </summary> /// <param name="resource">The subscription containing the role assignment</param> /// <param name="role">The object representing the role assignment</param> /// <returns>A <see cref="RoleAssignmentOperations"/> that allows getting and deleting RoleAssignments</returns> public static RoleAssignmentOperations RoleAssignmentAtScope(this SubscriptionOperations resource, RoleAssignmentData role) { return(new RoleAssignmentOperations(resource.ClientOptions, role)); }
/// <summary> /// Get RoleAssignment Operations for the given resource and scope. Note that this is only valid for unconstrained role assignments, so /// it is a generation-time decision if we include this. /// </summary> /// <param name="resource">The subscription containing the role assignment</param> /// <param name="resourceId">The id of the role assignment</param> /// <returns>A <see cref="RoleAssignmentOperations"/> that allows getting and deleting RoleAssignments</returns> public static RoleAssignmentOperations RoleAssignmentAtScope(this SubscriptionOperations resource, ResourceIdentifier resourceId) { return(new RoleAssignmentOperations(resource.ClientOptions, resourceId)); }
/// <summary> /// Get RoleAssignment Operations for the given resource and scope. Note that this is only valid for unconstrained role assignments, so /// it is a generation-time decision if we include this. /// </summary> /// <param name="resource">The subscription containing the role assignment</param> /// <param name="name">The name of the role assignment</param> /// <returns>A <see cref="RoleAssignmentOperations"/> that allows getting and deleting RoleAssignments</returns> public static RoleAssignmentOperations RoleAssignment(this SubscriptionOperations resource, string name) { return(new RoleAssignmentOperations(resource.ClientOptions, $"{resource.Id}/providers/Microsoft.Authorization/roleAssignments/{name}")); }
/// <summary> /// Get RoleAssignment Container for the given resource and scope. Note that this is only valid for unconstrained role assignments, so /// it is a generation-time decision if we include this. /// </summary> /// <param name="subscription">The subscription containign the role assignment</param> /// <param name="scope">The target of the role assignment</param> /// <returns>A <see cref="RoleAssignmentContainer"/> that allows creating and listing RoleAssignments</returns> public static RoleAssignmentContainer RoleAssigmentsAtScope(this SubscriptionOperations subscription, Resource scope) { return(new RoleAssignmentContainer(subscription.ClientOptions, scope.Id)); }
/// <summary> /// Get RoleAssignment Container for the given resource. Note that this is only valid for unconstrained role assignments, so /// it is a generation-time decision if we include this. /// </summary> /// <param name="resource">The subscription that is the target of the role assignemnt</param> /// <returns>A <see cref="RoleAssignmentContainer"/> that allows creating and listing RoleAssignments</returns> public static RoleAssignmentContainer RoleAssignments(this SubscriptionOperations resource) { return(new RoleAssignmentContainer(resource)); }