Skip to main content

policies

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

Overview

Namepolicies
TypeResource
Idazure.dev_test_labs.policies

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringThe identifier of the resource.
namestringThe name of the resource.
createdDatestring (date-time)The creation date of the policy.
descriptionstringThe description of the policy.
evaluatorTypestringThe evaluator type of the policy (i.e. AllowedValuesPolicy, MaxValuePolicy). Known values are: "AllowedValuesPolicy" and "MaxValuePolicy".
factDatastringThe fact data of the policy.
factNamestringThe fact name of the policy (e.g. LabVmCount, LabVmSize, MaxVmsAllowedPerLab, etc. Known values are: "UserOwnedLabVmCount", "UserOwnedLabPremiumVmCount", "LabVmCount", "LabPremiumVmCount", "LabVmSize", "GalleryImage", "UserOwnedLabVmCountInSubnet", "LabTargetCost", "EnvironmentTemplate", and "ScheduleEditPermission".
locationstringThe location of the resource.
provisioningStatestringThe provisioning status of the resource.
statusstringThe status of the policy. Known values are: "Enabled" and "Disabled".
tagsobjectThe tags of the resource.
thresholdstringThe threshold of the policy (i.e. a number for MaxValuePolicy, and a JSON array of values for AllowedValuesPolicy).
typestringThe type of the resource.
uniqueIdentifierstringThe unique immutable identifier of a resource (Guid).

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectresource_group_name, lab_name, policy_set_name, name, subscription_id$expandGet policy.
listselectresource_group_name, lab_name, policy_set_name, subscription_id$expand, $filter, $top, $orderbyList policies in a given policy set.
create_or_updateinsertresource_group_name, lab_name, policy_set_name, name, subscription_idCreate or replace an existing policy.
updateupdateresource_group_name, lab_name, policy_set_name, name, subscription_idAllows modifying tags of policies. All other properties will be ignored.
create_or_updatereplaceresource_group_name, lab_name, policy_set_name, name, subscription_idCreate or replace an existing policy.
deletedeleteresource_group_name, lab_name, policy_set_name, name, subscription_idDelete policy.

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
lab_namestringThe name of the lab. Required.
namestringThe name of the policy. Required.
policy_set_namestringThe name of the policy set. Required.
resource_group_namestringThe name of the resource group. Required.
subscription_idstring
$expandstringSpecify the $expand query. Example: 'properties($select=description)'. Default value is None.
$filterstringThe filter to apply to the operation. Example: '$filter=contains(name,'myName'). Default value is None.
$orderbystringThe ordering expression for the results, using OData notation. Example: '$orderby=name desc'. Default value is None.
$topintegerThe maximum number of resources to return from the operation. Example: '$top=10'. Default value is None.

SELECT examples

Get policy.

SELECT
id,
name,
createdDate,
description,
evaluatorType,
factData,
factName,
location,
provisioningState,
status,
tags,
threshold,
type,
uniqueIdentifier
FROM azure.dev_test_labs.policies
WHERE resource_group_name = '{{ resource_group_name }}' -- required
AND lab_name = '{{ lab_name }}' -- required
AND policy_set_name = '{{ policy_set_name }}' -- required
AND name = '{{ name }}' -- required
AND subscription_id = '{{ subscription_id }}' -- required
AND $expand = '{{ $expand }}'
;

INSERT examples

Create or replace an existing policy.

INSERT INTO azure.dev_test_labs.policies (
location,
tags,
properties,
resource_group_name,
lab_name,
policy_set_name,
name,
subscription_id
)
SELECT
'{{ location }}',
'{{ tags }}',
'{{ properties }}',
'{{ resource_group_name }}',
'{{ lab_name }}',
'{{ policy_set_name }}',
'{{ name }}',
'{{ subscription_id }}'
RETURNING
id,
name,
location,
properties,
tags,
type
;

UPDATE examples

Allows modifying tags of policies. All other properties will be ignored.

UPDATE azure.dev_test_labs.policies
SET
-- No updatable properties
WHERE
resource_group_name = '{{ resource_group_name }}' --required
AND lab_name = '{{ lab_name }}' --required
AND policy_set_name = '{{ policy_set_name }}' --required
AND name = '{{ name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
RETURNING
id,
name,
location,
properties,
tags,
type;

REPLACE examples

Create or replace an existing policy.

REPLACE azure.dev_test_labs.policies
SET
location = '{{ location }}',
tags = '{{ tags }}',
properties = '{{ properties }}'
WHERE
resource_group_name = '{{ resource_group_name }}' --required
AND lab_name = '{{ lab_name }}' --required
AND policy_set_name = '{{ policy_set_name }}' --required
AND name = '{{ name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
RETURNING
id,
name,
location,
properties,
tags,
type;

DELETE examples

Delete policy.

DELETE FROM azure.dev_test_labs.policies
WHERE resource_group_name = '{{ resource_group_name }}' --required
AND lab_name = '{{ lab_name }}' --required
AND policy_set_name = '{{ policy_set_name }}' --required
AND name = '{{ name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
;