Skip to main content

file_shares

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

Overview

Namefile_shares
TypeResource
Idazure.storage.file_shares

Fields

The following fields are returned by SELECT queries:

OK -- Get Share operation completed successfully.

NameDatatypeDescription
etagstringResource Etag.
propertiesobjectProperties of the file share. (x-ms-client-name: FileShareProperties)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectresourceGroupName, accountName, shareName, subscriptionId$expand, x-ms-snapshotGets properties of a specified share.
listselectresourceGroupName, accountName, subscriptionId$maxpagesize, $filter, $expandLists all shares.
createinsertresourceGroupName, accountName, shareName, subscriptionId$expandCreates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. It does not include a list of the files contained by the share.
updateupdateresourceGroupName, accountName, shareName, subscriptionIdUpdates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist.
deletedeleteresourceGroupName, accountName, shareName, subscriptionIdx-ms-snapshot, $includeDeletes specified share under its account.
restoreexecresourceGroupName, accountName, shareName, subscriptionId, deletedShareName, deletedShareVersionRestore a file share within a valid retention days if share soft delete is enabled
leaseexecresourceGroupName, accountName, shareName, subscriptionId, actionx-ms-snapshotThe Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite.

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
accountNamestringThe name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.
resourceGroupNamestringThe name of the resource group within the user's subscription. The name is case insensitive.
shareNamestringThe name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number.
subscriptionIdstring (uuid)The ID of the target subscription. The value must be an UUID.
$expandstringOptional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','
$filterstringOptional. When specified, only share names starting with the filter will be listed.
$includestringOptional. Valid values are: snapshots, leased-snapshots, none. The default value is snapshots. For 'snapshots', the file share is deleted including all of its file share snapshots. If the file share contains leased-snapshots, the deletion fails. For 'leased-snapshots', the file share is deleted included all of its file share snapshots (leased/unleased). For 'none', the file share is deleted if it has no share snapshots. If the file share contains any snapshots (leased or unleased), the deletion fails.
$maxpagesizestringOptional. Specified maximum number of shares that can be included in the list.
x-ms-snapshotstringOptional. Specify the snapshot time to lease a snapshot.

SELECT examples

Gets properties of a specified share.

SELECT
etag,
properties
FROM azure.storage.file_shares
WHERE resourceGroupName = '{{ resourceGroupName }}' -- required
AND accountName = '{{ accountName }}' -- required
AND shareName = '{{ shareName }}' -- required
AND subscriptionId = '{{ subscriptionId }}' -- required
AND $expand = '{{ $expand }}'
AND x-ms-snapshot = '{{ x-ms-snapshot }}'
;

INSERT examples

Creates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. It does not include a list of the files contained by the share.

INSERT INTO azure.storage.file_shares (
data__properties,
resourceGroupName,
accountName,
shareName,
subscriptionId,
$expand
)
SELECT
'{{ properties }}',
'{{ resourceGroupName }}',
'{{ accountName }}',
'{{ shareName }}',
'{{ subscriptionId }}',
'{{ $expand }}'
RETURNING
etag,
properties
;

UPDATE examples

Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist.

UPDATE azure.storage.file_shares
SET
data__properties = '{{ properties }}'
WHERE
resourceGroupName = '{{ resourceGroupName }}' --required
AND accountName = '{{ accountName }}' --required
AND shareName = '{{ shareName }}' --required
AND subscriptionId = '{{ subscriptionId }}' --required
RETURNING
etag,
properties;

DELETE examples

Deletes specified share under its account.

DELETE FROM azure.storage.file_shares
WHERE resourceGroupName = '{{ resourceGroupName }}' --required
AND accountName = '{{ accountName }}' --required
AND shareName = '{{ shareName }}' --required
AND subscriptionId = '{{ subscriptionId }}' --required
AND x-ms-snapshot = '{{ x-ms-snapshot }}'
AND $include = '{{ $include }}'
;

Lifecycle Methods

Restore a file share within a valid retention days if share soft delete is enabled

EXEC azure.storage.file_shares.restore 
@resourceGroupName='{{ resourceGroupName }}' --required,
@accountName='{{ accountName }}' --required,
@shareName='{{ shareName }}' --required,
@subscriptionId='{{ subscriptionId }}' --required
@@json=
'{
"deletedShareName": "{{ deletedShareName }}",
"deletedShareVersion": "{{ deletedShareVersion }}"
}'
;