Path - Create

Create File | Create Directory | Rename File | Rename Directory
Create or rename a file or directory. By default, the destination is overwritten and if the destination already exists and has a lease the lease is broken. Please note that renaming a file or directory into a container with an enforced container encryption policy is not allowed unless the source container also has an enforced container encryption policy that matches. This operation supports conditional HTTP requests. For more information, see Specifying Conditional Headers for Blob Service Operations. To fail if the destination already exists, use a conditional request with If-None-Match: "*".

PUT https://{accountName}.{dnsSuffix}/{filesystem}/{path}
PUT https://{accountName}.{dnsSuffix}/{filesystem}/{path}?resource={resource}&continuation={continuation}&mode={mode}&timeout={timeout}

URI Parameters

Name In Required Type Description
accountName
path True

string

The Azure Storage account name.

dnsSuffix
path True

string

The DNS suffix for the Azure Data Lake Storage endpoint.

filesystem
path True

string

The filesystem identifier.

Regex pattern: ^[$a-z0-9](?!.*--)[-a-z0-9]{1,61}[a-z0-9]$

path
path True

string

The file or directory path.

continuation
query

string

Optional. When renaming a directory, the number of paths that are renamed with each invocation is limited. If the number of paths to be renamed exceeds this limit, a continuation token is returned in this response header. When a continuation token is returned in the response, it must be specified in a subsequent invocation of the rename operation to continue renaming the directory.

mode
query

PathRenameMode

Optional. Valid only when namespace is enabled. This parameter determines the behavior of the rename operation. The value must be "legacy" or "posix", and the default value will be "posix".

resource
query

PathResourceType

Required only for Create File and Create Directory. The value must be "file" or "directory".

timeout
query

integer

int32

An optional operation timeout value in seconds. The period begins when the request is received by the service. If the timeout value elapses before the operation completes, the operation fails.

Request Header

Media Types: "application/octet-stream"

Name Required Type Description
Cache-Control

string

Optional. The service stores this value and includes it in the "Cache-Control" response header for "Read File" operations for "Read File" operations.

Content-Encoding

string

Optional. Specifies which content encodings have been applied to the file. This value is returned to the client when the "Read File" operation is performed.

Content-Language

string

Optional. Specifies the natural language used by the intended audience for the file.

Content-Disposition

string

Optional. The service stores this value and includes it in the "Content-Disposition" response header for "Read File" operations.

x-ms-cache-control

string

Optional. The service stores this value and includes it in the "Cache-Control" response header for "Read File" operations.

x-ms-content-type

string

Optional. The service stores this value and includes it in the "Content-Type" response header for "Read File" operations.

x-ms-content-encoding

string

Optional. The service stores this value and includes it in the "Content-Encoding" response header for "Read File" operations.

x-ms-content-language

string

Optional. The service stores this value and includes it in the "Content-Language" response header for "Read File" operations.

x-ms-content-disposition

string

Optional. The service stores this value and includes it in the "Content-Disposition" response header for "Read File" operations.

x-ms-rename-source

string

An optional file or directory to be renamed. The value must have the following format: "/{filesystem}/{path}", or "/{filesystem}/{path}?sastoken" when using a SAS token. If "x-ms-properties" is specified, the properties will overwrite the existing properties; otherwise, the existing properties will be preserved. This value must be a URL percent-encoded string. Note that the string may only contain ASCII characters in the ISO-8859-1 character set.

x-ms-lease-id

string

Optional. A lease ID for the path specified in the URI. The path to be overwritten must have an active lease and the lease ID must match.

Regex pattern: ^[{(]?[0-9a-f]{8}[-]?([0-9a-f]{4}[-]?){3}[0-9a-f]{12}[)}]?$

x-ms-source-lease-id

string

Optional for rename operations. A lease ID for the source path. The source path must have an active lease and the lease ID must match.

Regex pattern: ^[{(]?[0-9a-f]{8}[-]?([0-9a-f]{4}[-]?){3}[0-9a-f]{12}[)}]?$

x-ms-properties

string

Optional. User-defined properties to be stored with the file or directory, in the format of a comma-separated list of name and value pairs "n1=v1, n2=v2, ...", where each value is a base64 encoded string. Note that the string may only contain ASCII characters in the ISO-8859-1 character set.

x-ms-permissions

string

Optional and only valid if Hierarchical Namespace is enabled for the account. Sets POSIX access permissions for the file owner, the file owning group, and others. Each class may be granted read (4), write (2), or execute (1) permission. Both symbolic (rwxrw-rw-) and 4-digit octal notation (e.g. 0766) are supported. The sticky bit is also supported and in symbolic notation, its represented either by the letter t or T in the final character-place depending on whether the execution bit for the others category is set or unset respectively (e.g. rwxrw-rw- with sticky bit is represented as rwxrw-rwT. A rwxrw-rwx with sticky bit is represented as rwxrw-rwt), absence of t or T indicates sticky bit not set. In 4-digit octal notation, its represented by 1st digit (e.g. 1766 represents rwxrw-rw- with sticky bit and 0766 represents rwxrw-rw- without sticky bit). Invalid in conjunction with x-ms-acl.

x-ms-umask

string

Optional and only valid if Hierarchical Namespace is enabled for the account. When creating a file or directory and the parent folder does not have a default ACL, the umask restricts the permissions of the file or directory to be created. The resulting permission is given by p & ^u, where p is the permission and u is the umask. For example, if p is 0777 and u is 0057, then the resulting permission is 0720. The default permission is 0777 for a directory and 0666 for a file. The default umask is 0027. The umask must be specified in 4-digit octal notation (e.g. 0766).

x-ms-owner

string

Optional and only valid if Hierarchical Namespace is enabled for the account. Sets the owner of the file or directory.

x-ms-group

string

Optional and only valid if Hierarchical Namespace is enabled for the account. Sets the owning group of the file or directory.

x-ms-acl

string

Optional and only valid if Hierarchical Namespace is enabled for the account. Sets POSIX access control rights on files and directories. Each access control entry (ACE) consists of a scope, a type, a user or group identifier, and permissions in the format "[scope:][type]:[id]:[permissions]". The scope must be "default" to indicate the ACE belongs to the default ACL for a directory; otherwise scope is implicit and the ACE belongs to the access ACL. There are four ACE types: "user" grants rights to the owner or a named user, "group" grants rights to the owning group or a named group, "mask" restricts rights granted to named users and the members of groups, and "other" grants rights to all users not found in any of the other entries. The user or group identifier is omitted for entries of type "mask" and "other". The user or group identifier is also omitted for the owner and owning group. The permission field is a 3-character sequence where the first character is 'r' to grant read access, the second character is 'w' to grant write access, and the third character is 'x' to grant execute permission. If access is not granted, the '-' character is used to denote that the permission is denied. For example, the following ACL grants read, write, and execute rights to the file owner and john.doe@contoso, the read right to the owning group, and nothing to everyone else: "user::rwx,user:john.doe@contoso:rwx,group::r--,other::---,mask=rwx". Invalid in conjunction with x-ms-permissions.

x-ms-proposed-lease-id

string

Optional. Specify a proposed lease id if you want to acquire a lease during creation of a file or directory. A lease will be acquired with this lease ID if the creation is successful.

Regex pattern: ^[{(]?[0-9a-f]{8}[-]?([0-9a-f]{4}[-]?){3}[0-9a-f]{12}[)}]?$

x-ms-expiry-option

string

Optional and only valid if Hierarchical Namespace is enabled for the account and only supported on files. Specify one of the following expiry option if you want to set expiry time on a file while creation. "RelativeToNow" Set the expiry relative to the current time. User will pass the number of milliseconds elapsed from now. "Absolute" Absolute time in RFC 1123 Format. "Neverexpire" Set the file to never expire, expiry-time does not need to be specified with this option.

x-ms-expiry-time

string

Optional and only valid if Hierarchical Namespace is enabled for the account and only supported on files. Specify the expiry time when to expire the file. Given as RFC 1123 HTTP Time String or number of milliseconds according to the expiry-option.

If-Match

string

Optional. An ETag value. Specify this header to perform the operation only if the resource's ETag matches the value specified. The ETag must be specified in quotes.

If-None-Match

string

Optional. An ETag value or the special wildcard ("*") value. Specify this header to perform the operation only if the resource's ETag does not match the value specified. The ETag must be specified in quotes.

If-Modified-Since

string

Optional. A date and time value. Specify this header to perform the operation only if the resource has been modified since the specified date and time.

If-Unmodified-Since

string

Optional. A date and time value. Specify this header to perform the operation only if the resource has not been modified since the specified date and time.

x-ms-source-if-match

string

Optional. An ETag value. Specify this header to perform the rename operation only if the source's ETag matches the value specified. The ETag must be specified in quotes.

x-ms-source-if-none-match

string

Optional. An ETag value or the special wildcard ("*") value. Specify this header to perform the rename operation only if the source's ETag does not match the value specified. The ETag must be specified in quotes.

x-ms-source-if-modified-since

string

Optional. A date and time value. Specify this header to perform the rename operation only if the source has been modified since the specified date and time.

x-ms-source-if-unmodified-since

string

Optional. A date and time value. Specify this header to perform the rename operation only if the source has not been modified since the specified date and time.

x-ms-encryption-key

string

Optional. The Base64-encoded AES-256 encryption key.

x-ms-encryption-key-sha256

string

Optional. The Base64-encoded SHA256 hash of the encryption key.

x-ms-encryption-algorithm: AES256

string

Optional. Specifies the algorithm to use for encryption. The value of this header must be AES256.

x-ms-encryption-context

string

Optional. Default is “Empty”. If the value is set it will set Blob / File system metadata. Max length- 1024. Valid only when Hierarchical Namespace is enabled for the account.

x-ms-client-request-id

string

A UUID recorded in the analytics logs for troubleshooting and correlation.

Regex pattern: ^[{(]?[0-9a-f]{8}[-]?([0-9a-f]{4}[-]?){3}[0-9a-f]{12}[)}]?$

x-ms-date

string

Specifies the Coordinated Universal Time (UTC) for the request. This is required when using shared key authorization.

x-ms-version

string

Specifies the version of the REST protocol used for processing the request. This is required when using shared key authorization.

Responses

Name Type Description
201 Created

The file or directory was created.

Headers

  • Date: string
  • ETag: string
  • Last-Modified: string
  • x-ms-request-id: string
  • x-ms-version: string
  • x-ms-continuation: string
  • Content-Length: integer
  • x-ms-request-server-encrypted: true/false: boolean
  • x-ms-encryption-key-sha256: string
  • x-ms-encryption-scope: string
Other Status Codes

DataLakeStorageError

An error occurred. The possible HTTP status, code, and message strings are listed below:

  • 400 Bad Request, ContentLengthMustBeZero, "The Content-Length request header must be zero."
  • 400 Bad Request, InvalidAuthenticationInfo, "Authentication information is not given in the correct format. Check the value of Authorization header."
  • 400 Bad Request, InvalidFlushPosition, "The uploaded data is not contiguous or the position query parameter value is not equal to the length of the file after appending the uploaded data."
  • 400 Bad Request, InvalidHeaderValue, "The value for one of the HTTP headers is not in the correct format."
  • 400 Bad Request, InvalidHttpVerb, "The HTTP verb specified is invalid - it is not recognized by the server."
  • 400 Bad Request, InvalidInput, "One of the request inputs is not valid."
  • 400 Bad Request, InvalidPropertyName, "A property name cannot be empty."
  • 400 Bad Request, InvalidPropertyName, "The property name contains invalid characters."
  • 400 Bad Request, InvalidQueryParameterValue, "Value for one of the query parameters specified in the request URI is invalid."
  • 400 Bad Request, InvalidResourceName, "The specified resource name contains invalid characters."
  • 400 Bad Request, InvalidSourceUri, "The source URI is invalid."
  • 400 Bad Request, InvalidUri, "The request URI is invalid."
  • 400 Bad Request, MissingRequiredHeader, "An HTTP header that's mandatory for this request is not specified."
  • 400 Bad Request, MissingRequiredQueryParameter, "A query parameter that's mandatory for this request is not specified."
  • 400 Bad Request, MultipleConditionHeadersNotSupported, "Multiple condition headers are not supported."
  • 400 Bad Request, OutOfRangeInput, "One of the request inputs is out of range."
  • 400 Bad Request, OutOfRangeQueryParameterValue, "One of the query parameters specified in the request URI is outside the permissible range."
  • 400 Bad Request, UnsupportedHeader, "One of the headers specified in the request is not supported."
  • 400 Bad Request, UnsupportedQueryParameter, "One of the query parameters specified in the request URI is not supported."
  • 400 Bad Request, UnsupportedRestVersion, "The specified Rest Version is Unsupported."
  • 403 Forbidden, AccountIsDisabled, "The specified account is disabled."
  • 403 Forbidden, AuthorizationFailure, "This request is not authorized to perform this operation."
  • 403 Forbidden, InsufficientAccountPermissions, "The account being accessed does not have sufficient permissions to execute this operation."
  • 404 Not Found, FilesystemNotFound, "The specified filesystem does not exist."
  • 404 Not Found, PathNotFound, "The specified path does not exist."
  • 404 Not Found, RenameDestinationParentPathNotFound, "The parent directory of the destination path does not exist."
  • 404 Not Found, ResourceNotFound, "The specified resource does not exist."
  • 404 Not Found, SourcePathNotFound, "The source path for a rename operation does not exist."
  • 405 Method Not Allowed, UnsupportedHttpVerb, "The resource doesn't support the specified HTTP verb."
  • 409 Conflict, DestinationPathIsBeingDeleted, "The specified destination path is marked to be deleted."
  • 409 Conflict, DirectoryNotEmpty, "The recursive query parameter value must be true to delete a non-empty directory."
  • 409 Conflict, FilesystemAlreadyExists, "The specified filesystem already exists."
  • 409 Conflict, FilesystemBeingDeleted, "The specified filesystem is being deleted."
  • 409 Conflict, InvalidDestinationPath, "The specified path, or an element of the path, exists and its resource type is invalid for this operation."* 409 Conflict, InvalidFlushOperation, "The resource was created or modified by the Blob Service API and cannot be written to by the Data Lake Storage Service API."
  • 409 Conflict, InvalidRenameSourcePath, "The source directory cannot be the same as the destination directory, nor can the destination be a subdirectory of the source directory."
  • 409 Conflict, InvalidSourceOrDestinationResourceType, "The source and destination resource type must be identical."
  • 409 Conflict, LeaseAlreadyPresent, "There is already a lease present."
  • 409 Conflict, LeaseIdMismatchWithLeaseOperation, "The lease ID specified did not match the lease ID for the resource with the specified lease operation."
  • 409 Conflict, LeaseIsAlreadyBroken, "The lease has already been broken and cannot be broken again."
  • 409 Conflict, LeaseIsBreakingAndCannotBeAcquired, "The lease ID matched, but the lease is currently in breaking state and cannot be acquired until it is broken."
  • 409 Conflict, LeaseIsBreakingAndCannotBeChanged, "The lease ID matched, but the lease is currently in breaking state and cannot be changed."
  • 409 Conflict, LeaseIsBrokenAndCannotBeRenewed, "The lease ID matched, but the lease has been broken explicitly and cannot be renewed."
  • 409 Conflict, LeaseNameMismatch, "The lease name specified did not match the existing lease name."
  • 409 Conflict, LeaseNotPresentWithLeaseOperation, "The lease ID is not present with the specified lease operation."
  • 409 Conflict, PathAlreadyExists, "The specified path already exists."
  • 409 Conflict, PathConflict, "The specified path, or an element of the path, exists and its resource type is invalid for this operation."
  • 409 Conflict, SourcePathIsBeingDeleted, "The specified source path is marked to be deleted."
  • 409 Conflict, ResourceTypeMismatch, "The resource type specified in the request does not match the type of the resource."
  • 412 Precondition Failed, ConditionNotMet, "The condition specified using HTTP conditional header(s) is not met."
  • 412 Precondition Failed, LeaseIdMismatch, "The lease ID specified did not match the lease ID for the resource."
  • 412 Precondition Failed, LeaseIdMissing, "There is currently a lease on the resource and no lease ID was specified in the request."
  • 412 Precondition Failed, LeaseNotPresent, "There is currently no lease on the resource."
  • 412 Precondition Failed, LeaseLost, "A lease ID was specified, but the lease for the resource has expired."
  • 412 Precondition Failed, SourceConditionNotMet, "The source condition specified using HTTP conditional header(s) is not met."
  • 413 Request Entity Too Large, RequestBodyTooLarge, "The request body is too large and exceeds the maximum permissible limit."
  • 416 Requested Range Not Satisfiable, InvalidRange, "The range specified is invalid for the current size of the resource."
  • 500 Internal Server Error, InternalError, "The server encountered an internal error. Please retry the request."
  • 500 Internal Server Error, OperationTimedOut, "The operation could not be completed within the permitted time."
  • 503 Service Unavailable, ServerBusy, "Egress is over the account limit."
  • 503 Service Unavailable, ServerBusy, "Ingress is over the account limit."
  • 503 Service Unavailable, ServerBusy, "Operations per second is over the account limit."
  • 503 Service Unavailable, ServerBusy, "The server is currently unable to receive requests. Please retry your request."

Headers

  • x-ms-request-id: string
  • x-ms-version: string

Definitions

Name Description
DataLakeStorageError
Error

The service error response object.

PathRenameMode

Optional. Valid only when namespace is enabled. This parameter determines the behavior of the rename operation. The value must be "legacy" or "posix", and the default value will be "posix".

PathResourceType

Required only for Create File and Create Directory. The value must be "file" or "directory".

DataLakeStorageError

Name Type Description
error

Error

The service error response object.

Error

The service error response object.

Name Type Description
code

string

The service error code.

message

string

The service error message.

PathRenameMode

Optional. Valid only when namespace is enabled. This parameter determines the behavior of the rename operation. The value must be "legacy" or "posix", and the default value will be "posix".

Name Type Description
legacy

string

posix

string

PathResourceType

Required only for Create File and Create Directory. The value must be "file" or "directory".

Name Type Description
directory

string

file

string