{"record":{"id":"0a625278b29507cb","repo":"OrchardCMS/OrchardCore","slug":"cannot-create-directory-path","errorCode":null,"errorMessage":"Cannot create directory '{path}'.","messagePattern":"Cannot create directory '(.+?)'\\.","errorType":"exception","errorClass":"FileStoreException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.FileStorage.AzureBlob/BlobFileStore.cs","lineNumber":429,"sourceCode":"            {\n                yield return new BlobFile(RemoveBasePrefix(name), blob.Properties.ContentLength, blob.Properties.LastModified);\n            }\n        }\n    }\n\n    public async Task<bool> TryCreateDirectoryAsync(string path)\n    {\n        await EnsureCapabilitiesAsync();\n\n        if (_capabilities?.HasHierarchicalNamespace == true)\n        {\n            try\n            {\n                return await TryCreateDataLakeDirectoryAsync(path);\n            }\n            catch (Exception ex)\n            {\n                throw new FileStoreException($\"Cannot create directory '{path}'.\", ex);\n            }\n        }\n\n        // Since directories are only created implicitly when creating blobs, we\n        // simply pretend like we created the directory, unless there is already\n        // a blob with the same path.\n        try\n        {\n            var blobFile = GetBlobReference(path);\n\n            if (await blobFile.ExistsAsync())\n            {\n                throw new FileStoreException($\"Cannot create directory because the path '{path}' already exists and is a file.\");\n            }\n\n            var blobDirectory = await GetBlobDirectoryReference(path);\n            if (blobDirectory == null)\n            {","sourceCodeStart":411,"sourceCodeEnd":447,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.FileStorage.AzureBlob/BlobFileStore.cs#L411-L447","documentation":"In BlobFileStore.TryCreateDirectoryAsync, when the account uses Hierarchical Namespace the creation is done via TryCreateDataLakeDirectoryAsync; any exception there is wrapped in a FileStoreException with this message. Unlike the flat-namespace path (which pretends success), DataLake directories are real filesystem nodes, so a failure to create them is surfaced.","triggerScenarios":"Calling TryCreateDirectoryAsync on a Gen2/HNS account when the DataLake FileSystemClient.CreateDirectoryAsync (or equivalent) throws — permission denied on the filesystem, path conflicts with an existing blob, invalid path characters, or service errors.","commonSituations":"ACL/RBAC on the ADLS Gen2 filesystem denying write for the configured identity; creating a directory whose path collides with an existing blob name; invalid path segments (empty segments, illegal chars); transient service errors.","solutions":["Check the inner exception: 403 means grant Storage Blob Data Contributor (plus execute/Write ACLs) to the identity on the filesystem/path.","Verify the path is valid for DataLake (no empty segments, no illegal characters, not colliding with an existing file).","Confirm the account/filesystem (container) names are correct in options.","Retry on transient 5xx errors; the method normally returns false instead of throwing only for benign outcomes."],"exampleFix":"// before\nawait fileStore.TryCreateDirectoryAsync(\"reports//2026\"); // empty segment\n// after\nawait fileStore.TryCreateDirectoryAsync(\"reports/2026\");","handlingStrategy":"validation","validationCode":"var segments = path.Split('/', StringSplitOptions.RemoveEmptyEntries);\nif (segments.Length == 0 || segments.Any(string.IsNullOrWhiteSpace))\n{\n    return false; // reject invalid directory path before calling\n}\nif (await fileStore.GetFileInfoAsync(path) != null)\n{\n    return false; // path is an existing file\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var ok = await fileStore.TryCreateDirectoryAsync(path);\n    if (!ok) { /* handle benign failure */ }\n}\ncatch (FileStoreException ex)\n{\n    logger.LogError(ex.InnerException, \"DataLake directory creation failed for {Path}\", path);\n    // typically 403: grant Storage Blob Data Contributor + ACL execute/write\n}","preventionTips":["On ADLS Gen2, set RBAC (Storage Blob Data Contributor) and default ACLs covering create operations.","Validate path segments: no empty segments or illegal characters.","Check for file/directory name collisions before creating.","Retry transient 5xx; false return usually means it already existed."],"tags":["azure","data-lake-gen2","blob-storage","mkdir-permission-denied","file-storage"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}