Table of Contents

Class SubscriptionResource

Namespace
Azure.ResourceManager.Resources
Assembly
Azure.ResourceManager.dll

A class representing the operations that can be performed over a specific subscription.

public class SubscriptionResource : ArmResource, IJsonModel<SubscriptionData>, IPersistableModel<SubscriptionData>
Inheritance
SubscriptionResource
Implements
IJsonModel<SubscriptionData>
IPersistableModel<SubscriptionData>
Inherited Members

Constructors

SubscriptionResource()

Initializes a new instance of the SubscriptionResource class for mocking.

protected SubscriptionResource()

Fields

ResourceType

Gets the resource type for the operations.

public static readonly ResourceType ResourceType

Field Value

ResourceType

Properties

Data

Gets the data representing this Feature.

public virtual SubscriptionData Data { get; }

Property Value

SubscriptionData

Exceptions

InvalidOperationException

Throws if there is no data loaded in the current instance.

HasData

Gets whether or not the current instance has data.

public virtual bool HasData { get; }

Property Value

bool

Methods

CreateOrUpdatePredefinedTag(string, CancellationToken)

This operation allows adding a name to the list of predefined tag names for the given subscription. A tag name can have a maximum of 512 characters and is case-insensitive. Tag names cannot have the following prefixes which are reserved for Azure use: 'microsoft', 'azure', 'windows'.

  • Request Path/subscriptions/{subscriptionId}/tagNames/{tagName}
  • Operation IdTags_CreateOrUpdate
  • Default Api Version2022-09-01
public virtual Response<PredefinedTag> CreateOrUpdatePredefinedTag(string tagName, CancellationToken cancellationToken = default)

Parameters

tagName string

The name of the tag to create.

cancellationToken CancellationToken

The cancellation token to use.

Returns

Response<PredefinedTag>

Exceptions

ArgumentException

tagName is an empty string, and was expected to be non-empty.

ArgumentNullException

tagName is null.

CreateOrUpdatePredefinedTagAsync(string, CancellationToken)

This operation allows adding a name to the list of predefined tag names for the given subscription. A tag name can have a maximum of 512 characters and is case-insensitive. Tag names cannot have the following prefixes which are reserved for Azure use: 'microsoft', 'azure', 'windows'.

  • Request Path/subscriptions/{subscriptionId}/tagNames/{tagName}
  • Operation IdTags_CreateOrUpdate
  • Default Api Version2022-09-01
public virtual Task<Response<PredefinedTag>> CreateOrUpdatePredefinedTagAsync(string tagName, CancellationToken cancellationToken = default)

Parameters

tagName string

The name of the tag to create.

cancellationToken CancellationToken

The cancellation token to use.

Returns

Task<Response<PredefinedTag>>

Exceptions

ArgumentException

tagName is an empty string, and was expected to be non-empty.

ArgumentNullException

tagName is null.

CreateOrUpdatePredefinedTagValue(string, string, CancellationToken)

This operation allows adding a value to the list of predefined values for an existing predefined tag name. A tag value can have a maximum of 256 characters.

  • Request Path/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}
  • Operation IdTags_CreateOrUpdateValue
  • Default Api Version2022-09-01
public virtual Response<PredefinedTagValue> CreateOrUpdatePredefinedTagValue(string tagName, string tagValue, CancellationToken cancellationToken = default)

Parameters

tagName string

The name of the tag.

tagValue string

The value of the tag to create.

cancellationToken CancellationToken

The cancellation token to use.

Returns

Response<PredefinedTagValue>

Exceptions

ArgumentException

tagName or tagValue is an empty string, and was expected to be non-empty.

ArgumentNullException

tagName or tagValue is null.

CreateOrUpdatePredefinedTagValueAsync(string, string, CancellationToken)

This operation allows adding a value to the list of predefined values for an existing predefined tag name. A tag value can have a maximum of 256 characters.

  • Request Path/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}
  • Operation IdTags_CreateOrUpdateValue
  • Default Api Version2022-09-01
public virtual Task<Response<PredefinedTagValue>> CreateOrUpdatePredefinedTagValueAsync(string tagName, string tagValue, CancellationToken cancellationToken = default)

Parameters

tagName string

The name of the tag.

tagValue string

The value of the tag to create.

cancellationToken CancellationToken

The cancellation token to use.

Returns

Task<Response<PredefinedTagValue>>

Exceptions

ArgumentException

tagName or tagValue is an empty string, and was expected to be non-empty.

ArgumentNullException

tagName or tagValue is null.

CreateResourceIdentifier(string)

Generate the resource identifier of a SubscriptionResource instance.

public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId)

Parameters

subscriptionId string

The subscriptionId.

Returns

ResourceIdentifier

DeletePredefinedTag(string, CancellationToken)

This operation allows deleting a name from the list of predefined tag names for the given subscription. The name being deleted must not be in use as a tag name for any resource. All predefined values for the given name must have already been deleted.

  • Request Path/subscriptions/{subscriptionId}/tagNames/{tagName}
  • Operation IdTags_Delete
  • Default Api Version2022-09-01
public virtual Response DeletePredefinedTag(string tagName, CancellationToken cancellationToken = default)

Parameters

tagName string

The name of the tag.

cancellationToken CancellationToken

The cancellation token to use.

Returns

Response

Exceptions

ArgumentException

tagName is an empty string, and was expected to be non-empty.

ArgumentNullException

tagName is null.

DeletePredefinedTagAsync(string, CancellationToken)

This operation allows deleting a name from the list of predefined tag names for the given subscription. The name being deleted must not be in use as a tag name for any resource. All predefined values for the given name must have already been deleted.

  • Request Path/subscriptions/{subscriptionId}/tagNames/{tagName}
  • Operation IdTags_Delete
  • Default Api Version2022-09-01
public virtual Task<Response> DeletePredefinedTagAsync(string tagName, CancellationToken cancellationToken = default)

Parameters

tagName string

The name of the tag.

cancellationToken CancellationToken

The cancellation token to use.

Returns

Task<Response>

Exceptions

ArgumentException

tagName is an empty string, and was expected to be non-empty.

ArgumentNullException

tagName is null.

DeletePredefinedTagValue(string, string, CancellationToken)

This operation allows deleting a value from the list of predefined values for an existing predefined tag name. The value being deleted must not be in use as a tag value for the given tag name for any resource.

  • Request Path/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}
  • Operation IdTags_DeleteValue
  • Default Api Version2022-09-01
public virtual Response DeletePredefinedTagValue(string tagName, string tagValue, CancellationToken cancellationToken = default)

Parameters

tagName string

The name of the tag.

tagValue string

The value of the tag to delete.

cancellationToken CancellationToken

The cancellation token to use.

Returns

Response

Exceptions

ArgumentException

tagName or tagValue is an empty string, and was expected to be non-empty.

ArgumentNullException

tagName or tagValue is null.

DeletePredefinedTagValueAsync(string, string, CancellationToken)

This operation allows deleting a value from the list of predefined values for an existing predefined tag name. The value being deleted must not be in use as a tag value for the given tag name for any resource.

  • Request Path/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}
  • Operation IdTags_DeleteValue
  • Default Api Version2022-09-01
public virtual Task<Response> DeletePredefinedTagValueAsync(string tagName, string tagValue, CancellationToken cancellationToken = default)

Parameters

tagName string

The name of the tag.

tagValue string

The value of the tag to delete.

cancellationToken CancellationToken

The cancellation token to use.

Returns

Task<Response>

Exceptions

ArgumentException

tagName or tagValue is an empty string, and was expected to be non-empty.

ArgumentNullException

tagName or tagValue is null.

Get(CancellationToken)

Gets details about a specified subscription.

  • Request Path/subscriptions/{subscriptionId}
  • Operation IdSubscriptions_Get
  • Default Api Version2022-12-01
  • ResourceSubscriptionResource
public virtual Response<SubscriptionResource> Get(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The cancellation token to use.

Returns

Response<SubscriptionResource>

GetAllPredefinedTags(CancellationToken)

This operation performs a union of predefined tags, resource tags, resource group tags and subscription tags, and returns a summary of usage for each tag name and value under the given subscription. In case of a large number of tags, this operation may return a previously cached result.

  • Request Path/subscriptions/{subscriptionId}/tagNames
  • Operation IdTags_List
  • Default Api Version2022-09-01
  • ResourceSubscriptionResource
public virtual Pageable<PredefinedTag> GetAllPredefinedTags(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The cancellation token to use.

Returns

Pageable<PredefinedTag>

A collection of PredefinedTag that may take multiple service requests to iterate over.

GetAllPredefinedTagsAsync(CancellationToken)

This operation performs a union of predefined tags, resource tags, resource group tags and subscription tags, and returns a summary of usage for each tag name and value under the given subscription. In case of a large number of tags, this operation may return a previously cached result.

  • Request Path/subscriptions/{subscriptionId}/tagNames
  • Operation IdTags_List
  • Default Api Version2022-09-01
  • ResourceSubscriptionResource
public virtual AsyncPageable<PredefinedTag> GetAllPredefinedTagsAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The cancellation token to use.

Returns

AsyncPageable<PredefinedTag>

An async collection of PredefinedTag that may take multiple service requests to iterate over.

GetArmRestApis(string)

Gets the RestApi definition for a given Azure namespace.

public virtual ArmRestApiCollection GetArmRestApis(string azureNamespace)

Parameters

azureNamespace string

The namespace to get the rest API for.

Returns

ArmRestApiCollection

A collection representing the rest apis for the namespace.

GetAsync(CancellationToken)

Gets details about a specified subscription.

  • Request Path/subscriptions/{subscriptionId}
  • Operation IdSubscriptions_Get
  • Default Api Version2022-12-01
  • ResourceSubscriptionResource
public virtual Task<Response<SubscriptionResource>> GetAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The cancellation token to use.

Returns

Task<Response<SubscriptionResource>>

GetFeatures(CancellationToken)

Gets all the preview features that are available through AFEC for the subscription.

  • Request Path/subscriptions/{subscriptionId}/providers/Microsoft.Features/features
  • Operation IdFeatures_ListAll
  • Default Api Version2021-07-01
  • ResourceFeatureResource
public virtual Pageable<FeatureResource> GetFeatures(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The cancellation token to use.

Returns

Pageable<FeatureResource>

A collection of FeatureResource that may take multiple service requests to iterate over.

GetFeaturesAsync(CancellationToken)

Gets all the preview features that are available through AFEC for the subscription.

  • Request Path/subscriptions/{subscriptionId}/providers/Microsoft.Features/features
  • Operation IdFeatures_ListAll
  • Default Api Version2021-07-01
  • ResourceFeatureResource
public virtual AsyncPageable<FeatureResource> GetFeaturesAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The cancellation token to use.

Returns

AsyncPageable<FeatureResource>

An async collection of FeatureResource that may take multiple service requests to iterate over.

GetGenericResources(string, string, int?, CancellationToken)

Get all the resources in a subscription.

public virtual Pageable<GenericResource> GetGenericResources(string filter = null, string expand = null, int? top = null, CancellationToken cancellationToken = default)

Parameters

filter string

The filter to apply on the operation.<br><br>The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, and plan/promotionCode.<br><br>For example, to filter by a resource type, use: $filter=resourceType eq 'Microsoft.Network/virtualNetworks'<br><br>You can use substringof(value, property) in the filter. The properties you can use for substring are: name and resourceGroup.<br><br>For example, to get all resources with 'demo' anywhere in the name, use: $filter=substringof('demo', name)<br><br>You can link more than one substringof together by adding and/or operators.<br><br>You can filter by tag names and values. For example, to filter for a tag name and value, use $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When you filter by a tag name and value, the tags for each resource are not returned in the results.<br><br>You can use some properties together when filtering. The combinations you can use are: substringof and/or resourceType, plan and plan/publisher and plan/name, identity and identity/principalId.

expand string

Comma-separated list of additional properties to be included in the response. Valid values include createdTime, changedTime and provisioningState. For example, $expand=createdTime,changedTime.

top int?

The number of results to return. If null is passed, returns all resource groups.

cancellationToken CancellationToken

The cancellation token to use.

Returns

Pageable<GenericResource>

A collection of GenericResource that may take multiple service requests to iterate over.

GetGenericResourcesAsync(string, string, int?, CancellationToken)

Get all the resources in a subscription.

public virtual AsyncPageable<GenericResource> GetGenericResourcesAsync(string filter = null, string expand = null, int? top = null, CancellationToken cancellationToken = default)

Parameters

filter string

The filter to apply on the operation.<br><br>The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, and plan/promotionCode.<br><br>For example, to filter by a resource type, use: $filter=resourceType eq 'Microsoft.Network/virtualNetworks'<br><br>You can use substringof(value, property) in the filter. The properties you can use for substring are: name and resourceGroup.<br><br>For example, to get all resources with 'demo' anywhere in the name, use: $filter=substringof('demo', name)<br><br>You can link more than one substringof together by adding and/or operators.<br><br>You can filter by tag names and values. For example, to filter for a tag name and value, use $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When you filter by a tag name and value, the tags for each resource are not returned in the results.<br><br>You can use some properties together when filtering. The combinations you can use are: substringof and/or resourceType, plan and plan/publisher and plan/name, identity and identity/principalId.

expand string

Comma-separated list of additional properties to be included in the response. Valid values include createdTime, changedTime and provisioningState. For example, $expand=createdTime,changedTime.

top int?

The number of results to return. If null is passed, returns all resource groups.

cancellationToken CancellationToken

The cancellation token to use.

Returns

AsyncPageable<GenericResource>

An async collection of GenericResource that may take multiple service requests to iterate over.

GetLocations(bool?, CancellationToken)

This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list.

  • Request Path/subscriptions/{subscriptionId}/locations
  • Operation IdSubscriptions_ListLocations
  • Default Api Version2022-12-01
  • ResourceSubscriptionResource
public virtual Pageable<LocationExpanded> GetLocations(bool? includeExtendedLocations = null, CancellationToken cancellationToken = default)

Parameters

includeExtendedLocations bool?

Whether to include extended locations.

cancellationToken CancellationToken

The cancellation token to use.

Returns

Pageable<LocationExpanded>

A collection of LocationExpanded that may take multiple service requests to iterate over.

GetLocationsAsync(bool?, CancellationToken)

This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list.

  • Request Path/subscriptions/{subscriptionId}/locations
  • Operation IdSubscriptions_ListLocations
  • Default Api Version2022-12-01
  • ResourceSubscriptionResource
public virtual AsyncPageable<LocationExpanded> GetLocationsAsync(bool? includeExtendedLocations = null, CancellationToken cancellationToken = default)

Parameters

includeExtendedLocations bool?

Whether to include extended locations.

cancellationToken CancellationToken

The cancellation token to use.

Returns

AsyncPageable<LocationExpanded>

An async collection of LocationExpanded that may take multiple service requests to iterate over.

GetResourceGroup(string, CancellationToken)

Gets a resource group.

  • Request Path/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}
  • Operation IdResourceGroups_Get
  • Default Api Version2022-09-01
  • ResourceResourceGroupResource
public virtual Response<ResourceGroupResource> GetResourceGroup(string resourceGroupName, CancellationToken cancellationToken = default)

Parameters

resourceGroupName string

The name of the resource group to get. The name is case insensitive.

cancellationToken CancellationToken

The cancellation token to use.

Returns

Response<ResourceGroupResource>

Exceptions

ArgumentNullException

resourceGroupName is null.

ArgumentException

resourceGroupName is an empty string, and was expected to be non-empty.

GetResourceGroupAsync(string, CancellationToken)

Gets a resource group.

  • Request Path/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}
  • Operation IdResourceGroups_Get
  • Default Api Version2022-09-01
  • ResourceResourceGroupResource
public virtual Task<Response<ResourceGroupResource>> GetResourceGroupAsync(string resourceGroupName, CancellationToken cancellationToken = default)

Parameters

resourceGroupName string

The name of the resource group to get. The name is case insensitive.

cancellationToken CancellationToken

The cancellation token to use.

Returns

Task<Response<ResourceGroupResource>>

Exceptions

ArgumentNullException

resourceGroupName is null.

ArgumentException

resourceGroupName is an empty string, and was expected to be non-empty.

GetResourceGroups()

Gets a collection of ResourceGroupResources in the Subscription.

public virtual ResourceGroupCollection GetResourceGroups()

Returns

ResourceGroupCollection

An object representing collection of ResourceGroupResources and their operations over a ResourceGroupResource.

GetResourceProvider(string, string, CancellationToken)

Gets the specified resource provider.

  • Request Path/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}
  • Operation IdProviders_Get
  • Default Api Version2022-09-01
  • ResourceResourceProviderResource
public virtual Response<ResourceProviderResource> GetResourceProvider(string resourceProviderNamespace, string expand = null, CancellationToken cancellationToken = default)

Parameters

resourceProviderNamespace string

The namespace of the resource provider.

expand string

The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases.

cancellationToken CancellationToken

The cancellation token to use.

Returns

Response<ResourceProviderResource>

Exceptions

ArgumentNullException

resourceProviderNamespace is null.

ArgumentException

resourceProviderNamespace is an empty string, and was expected to be non-empty.

GetResourceProviderAsync(string, string, CancellationToken)

Gets the specified resource provider.

  • Request Path/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}
  • Operation IdProviders_Get
  • Default Api Version2022-09-01
  • ResourceResourceProviderResource
public virtual Task<Response<ResourceProviderResource>> GetResourceProviderAsync(string resourceProviderNamespace, string expand = null, CancellationToken cancellationToken = default)

Parameters

resourceProviderNamespace string

The namespace of the resource provider.

expand string

The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases.

cancellationToken CancellationToken

The cancellation token to use.

Returns

Task<Response<ResourceProviderResource>>

Exceptions

ArgumentNullException

resourceProviderNamespace is null.

ArgumentException

resourceProviderNamespace is an empty string, and was expected to be non-empty.

GetResourceProviders()

Gets a collection of ResourceProviderResources in the Subscription.

public virtual ResourceProviderCollection GetResourceProviders()

Returns

ResourceProviderCollection

An object representing collection of ResourceProviderResources and their operations over a ResourceProviderResource.

GetSubscriptionPolicyDefinition(string, CancellationToken)

This operation retrieves the policy definition in the given subscription with the given name.

  • Request Path/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}
  • Operation IdPolicyDefinitions_Get
  • Default Api Version2021-06-01
  • ResourceSubscriptionPolicyDefinitionResource
public virtual Response<SubscriptionPolicyDefinitionResource> GetSubscriptionPolicyDefinition(string policyDefinitionName, CancellationToken cancellationToken = default)

Parameters

policyDefinitionName string

The name of the policy definition to get.

cancellationToken CancellationToken

The cancellation token to use.

Returns

Response<SubscriptionPolicyDefinitionResource>

Exceptions

ArgumentNullException

policyDefinitionName is null.

ArgumentException

policyDefinitionName is an empty string, and was expected to be non-empty.

GetSubscriptionPolicyDefinitionAsync(string, CancellationToken)

This operation retrieves the policy definition in the given subscription with the given name.

  • Request Path/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}
  • Operation IdPolicyDefinitions_Get
  • Default Api Version2021-06-01
  • ResourceSubscriptionPolicyDefinitionResource
public virtual Task<Response<SubscriptionPolicyDefinitionResource>> GetSubscriptionPolicyDefinitionAsync(string policyDefinitionName, CancellationToken cancellationToken = default)

Parameters

policyDefinitionName string

The name of the policy definition to get.

cancellationToken CancellationToken

The cancellation token to use.

Returns

Task<Response<SubscriptionPolicyDefinitionResource>>

Exceptions

ArgumentNullException

policyDefinitionName is null.

ArgumentException

policyDefinitionName is an empty string, and was expected to be non-empty.

GetSubscriptionPolicyDefinitions()

Gets a collection of SubscriptionPolicyDefinitionResources in the Subscription.

public virtual SubscriptionPolicyDefinitionCollection GetSubscriptionPolicyDefinitions()

Returns

SubscriptionPolicyDefinitionCollection

An object representing collection of SubscriptionPolicyDefinitionResources and their operations over a SubscriptionPolicyDefinitionResource.

GetSubscriptionPolicySetDefinition(string, CancellationToken)

This operation retrieves the policy set definition in the given subscription with the given name.

  • Request Path/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}
  • Operation IdPolicySetDefinitions_Get
  • Default Api Version2021-06-01
  • ResourceSubscriptionPolicySetDefinitionResource
public virtual Response<SubscriptionPolicySetDefinitionResource> GetSubscriptionPolicySetDefinition(string policySetDefinitionName, CancellationToken cancellationToken = default)

Parameters

policySetDefinitionName string

The name of the policy set definition to get.

cancellationToken CancellationToken

The cancellation token to use.

Returns

Response<SubscriptionPolicySetDefinitionResource>

Exceptions

ArgumentNullException

policySetDefinitionName is null.

ArgumentException

policySetDefinitionName is an empty string, and was expected to be non-empty.

GetSubscriptionPolicySetDefinitionAsync(string, CancellationToken)

This operation retrieves the policy set definition in the given subscription with the given name.

  • Request Path/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}
  • Operation IdPolicySetDefinitions_Get
  • Default Api Version2021-06-01
  • ResourceSubscriptionPolicySetDefinitionResource
public virtual Task<Response<SubscriptionPolicySetDefinitionResource>> GetSubscriptionPolicySetDefinitionAsync(string policySetDefinitionName, CancellationToken cancellationToken = default)

Parameters

policySetDefinitionName string

The name of the policy set definition to get.

cancellationToken CancellationToken

The cancellation token to use.

Returns

Task<Response<SubscriptionPolicySetDefinitionResource>>

Exceptions

ArgumentNullException

policySetDefinitionName is null.

ArgumentException

policySetDefinitionName is an empty string, and was expected to be non-empty.

GetSubscriptionPolicySetDefinitions()

Gets a collection of SubscriptionPolicySetDefinitionResources in the Subscription.

public virtual SubscriptionPolicySetDefinitionCollection GetSubscriptionPolicySetDefinitions()

Returns

SubscriptionPolicySetDefinitionCollection

An object representing collection of SubscriptionPolicySetDefinitionResources and their operations over a SubscriptionPolicySetDefinitionResource.