Del via


Set Share Metadata

The Set Share Metadata operation sets one or more user-defined name/value pairs for the specified share. Although this operation is fully supported, it's a legacy management operation. We recommend that you use the File Shares - Update operation provided by the storage resource provider (Microsoft.Storage) instead. To learn more about programmatically interacting with FileShare resources by using the storage resource provider, see Operations on FileShare resources.

Protocol availability

Enabled file share protocol Available
SMB Yes
NFS Yes

Request

You construct the Set Share Metadata request as follows. We recommend HTTPS. Replace myaccount with the name of your storage account.

Method Request URI HTTP version
PUT https://myaccount.file.core.windows.net/myshare?restype=share&comp=metadata HTTP/1.1

Replace the path components shown in the request URI with your own, as follows:

Path component Description
myaccount The name of your storage account.
myshare The name of your file share.

For details on path naming restrictions, see Naming and referencing shares, directories, files, and metadata.

URI parameters

You can specify the following additional parameters on the request URI:

Parameter Description
timeout Optional. Expressed in seconds. For more information, see Set timeouts for Azure Files operations.

Request headers

The following table describes required and optional request headers:

Request header Description
Authorization Required. Specifies the authorization scheme, account name, and signature. For more information, see Authorize requests to Azure Storage.
Date or x-ms-date Required. Specifies the Coordinated Universal Time (UTC) for the request. For more information, see Authorize requests to Azure Storage.
x-ms-version Required for all authorized requests. Specifies the version of the operation to use for this request. For more information, see Versioning for the Azure Storage services.
x-ms-meta-name:value Optional. Provides a name/value pair to contain metadata for the share.

Each call to this operation replaces all existing metadata attached to the share. To remove all metadata from the share, call this operation with no metadata headers.

Metadata names must adhere to the naming rules for C# identifiers.
x-ms-client-request-id Optional. Provides a client-generated, opaque value with a 1-kibibyte (KiB) character limit that's recorded in the Storage Analytics logs when logging is configured. We highly recommend that you use this header to correlate client-side activities with requests that the server receives. For more information, see Monitor Azure Blob Storage.
x-ms-lease-id:<ID> Required if the destination file share has an active lease. Available for version 2020-02-10 and later. If the request doesn't include the lease ID or it isn't valid, the operation fails with status code 412 (Precondition Failed).

If this header is specified and the destination file share doesn't currently have an active lease, the operation fails with status code 412 (Precondition Failed).

Request body

None.

Sample request

PUT https://myaccount.file.core.windows.net/myshare?restype=share&comp=metadata HTTP/1.1  
  
Request Headers:  
x-ms-version: 2014-02-14  
x-ms-date: Mon, 27 Jan 2014 22:50:32 GMT  
x-ms-meta-Category: Images  
Authorization: SharedKey myaccount:Z5043vY9MesKNh0PNtksNc9nbXSSqGHueE00JdjidOQ=  

Response

The response includes an HTTP status code and a set of response headers.

Status code

A successful operation returns status code 200 (OK).

For information about status codes, see Status and error codes.

Response headers

The response for this operation includes the following headers. The response might also include additional standard HTTP headers. All standard headers conform to the HTTP/1.1 protocol specification.

Response header Description
Last-Modified Returns the date and time that the share was last modified. The date format follows RFC 1123. For more information, see Representation of date/time values in headers. Any operation that modifies the share or its properties updates the last modified time. Operations on files don't affect the last modified time of the share.
ETag Contains a value that represents the version of the share, in quotation marks.
x-ms-request-id Uniquely identifies the request that was made. You can use it to troubleshoot the request. For more information, see Troubleshoot API operations.
x-ms-version Indicates the version of Azure Files that was used to execute the request.
Date or x-ms-date A UTC date/time value that indicates the time at which the service sent the response.
x-ms-client-request-id Can be used to troubleshoot requests and corresponding responses. The value of this header is equal to the value of the x-ms-client-request-id header, if it's present in the request and the value is at most 1,024 visible ASCII characters. If the x-ms-client-request-id header is not present in the request, this header won't be present in the response.

Response body

None.

Authorization

Only the account owner can call this operation.

Remarks

Calling Set Share Metadata overwrites all existing metadata that's associated with the share. It's not possible to modify an individual name/value pair.

You can also set metadata for a share at the time that it's created, as part of the Create Share operation.

Calling Set Share Metadata updates the ETag and Last-Modified-Time properties for the share.

Set Share Metadata is not supported for a share snapshot. An attempt to perform this operation on a share snapshot will fail with status code 400 (InvalidQueryParameterValue). You can set metadata for a share snapshot at the time that it's created, as part of the Snapshot Share operation.

See also

Operations on FileShare resources (Azure Files)