Skip to main content

resource_groups

Creates, updates, deletes, gets or lists a resource_groups resource.

Overview

Nameresource_groups
TypeResource
Idazure.resources.resource_groups

Fields

The following fields are returned by SELECT queries:

OK - Returns information about the resource group.

NameDatatypeDescription
idstringThe ID of the resource group.
namestringThe name of the resource group.
locationstringThe location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations.
managedBystringThe ID of the resource that manages this resource group.
propertiesobjectThe resource group properties.
tagsobjectThe tags attached to the resource group.
typestringThe type of the resource group.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectresourceGroupName, subscriptionIdGets a resource group.
listselectsubscriptionId$filter, $topGets all the resource groups for a subscription.
create_or_updateinsertresourceGroupName, subscriptionId, data__locationCreates or updates a resource group.
updateupdateresourceGroupName, subscriptionIdResource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained.
deletedeleteresourceGroupName, subscriptionIdforceDeletionTypesWhen you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations.
export_templateexecsubscriptionId, resourceGroupNameCaptures the specified resource group as a template.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
resourceGroupNamestringThe name of the resource group. The name is case insensitive.
subscriptionIdstring (uuid)The ID of the target subscription. The value must be an UUID.
$filterstringThe filter to apply on the operation.

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'
$topinteger (int32)The number of results to return. If null is passed, returns all resource groups.
forceDeletionTypesstringThe resource types you want to force delete. Currently, only the following is supported: forceDeletionTypes=Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets

SELECT examples

Gets a resource group.

SELECT
id,
name,
location,
managedBy,
properties,
tags,
type
FROM azure.resources.resource_groups
WHERE resourceGroupName = '{{ resourceGroupName }}' -- required
AND subscriptionId = '{{ subscriptionId }}' -- required
;

INSERT examples

Creates or updates a resource group.

INSERT INTO azure.resources.resource_groups (
data__properties,
data__location,
data__managedBy,
data__tags,
resourceGroupName,
subscriptionId
)
SELECT
'{{ properties }}',
'{{ location }}' /* required */,
'{{ managedBy }}',
'{{ tags }}',
'{{ resourceGroupName }}',
'{{ subscriptionId }}'
RETURNING
id,
name,
location,
managedBy,
properties,
tags,
type
;

UPDATE examples

Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained.

UPDATE azure.resources.resource_groups
SET
data__name = '{{ name }}',
data__properties = '{{ properties }}',
data__managedBy = '{{ managedBy }}',
data__tags = '{{ tags }}'
WHERE
resourceGroupName = '{{ resourceGroupName }}' --required
AND subscriptionId = '{{ subscriptionId }}' --required
RETURNING
id,
name,
location,
managedBy,
properties,
tags,
type;

DELETE examples

When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations.

DELETE FROM azure.resources.resource_groups
WHERE resourceGroupName = '{{ resourceGroupName }}' --required
AND subscriptionId = '{{ subscriptionId }}' --required
AND forceDeletionTypes = '{{ forceDeletionTypes }}'
;

Lifecycle Methods

Captures the specified resource group as a template.

EXEC azure.resources.resource_groups.export_template 
@subscriptionId='{{ subscriptionId }}' --required,
@resourceGroupName='{{ resourceGroupName }}' --required
@@json=
'{
"resources": "{{ resources }}",
"options": "{{ options }}",
"outputFormat": "{{ outputFormat }}"
}'
;