Azure Blob
Stores files in Azure Blob Storage containers. For interface details, see WorkspaceFilesystem Interface.
InstallationInstallation的直接链接
- npm
- pnpm
- Yarn
- Bun
npm install @mastra/azure
pnpm add @mastra/azure
yarn add @mastra/azure
bun add @mastra/azure
UsageUsage的直接链接
Add an AzureBlobFilesystem to a workspace and assign it to an agent:
import { Agent } from '@mastra/core/agent'
import { Workspace } from '@mastra/core/workspace'
import { AzureBlobFilesystem } from '@mastra/azure/blob'
const workspace = new Workspace({
filesystem: new AzureBlobFilesystem({
container: 'my-container',
connectionString: process.env.AZURE_STORAGE_CONNECTION_STRING,
}),
})
const agent = new Agent({
id: 'file-agent',
name: 'file-agent',
model: 'anthropic/claude-opus-4-7',
workspace,
})
Account keyAccount key的直接链接
Use an account name and account key when you don't want to pass a full connection string:
import { AzureBlobFilesystem } from '@mastra/azure/blob'
const filesystem = new AzureBlobFilesystem({
container: 'my-container',
accountName: process.env.AZURE_STORAGE_ACCOUNT_NAME,
accountKey: process.env.AZURE_STORAGE_ACCOUNT_KEY,
})
Shared access signature tokenShared access signature token的直接链接
Use a shared access signature (SAS) token with either accountName or endpoint:
import { AzureBlobFilesystem } from '@mastra/azure/blob'
const filesystem = new AzureBlobFilesystem({
container: 'my-container',
accountName: process.env.AZURE_STORAGE_ACCOUNT_NAME,
sasToken: process.env.AZURE_STORAGE_SAS_TOKEN,
})
DefaultAzureCredentialDefaultAzureCredential的直接链接
Use DefaultAzureCredential when your environment provides Azure identity credentials:
import { AzureBlobFilesystem } from '@mastra/azure/blob'
const filesystem = new AzureBlobFilesystem({
container: 'my-container',
accountName: process.env.AZURE_STORAGE_ACCOUNT_NAME,
useDefaultCredential: true,
})
Install @azure/identity when you use DefaultAzureCredential:
- npm
- pnpm
- Yarn
- Bun
npm install @azure/identity
pnpm add @azure/identity
yarn add @azure/identity
bun add @azure/identity
Constructor parametersConstructor parameters的直接链接
container:
connectionString?:
accountName?:
accountKey?:
sasToken?:
useDefaultCredential?:
endpoint?:
prefix?:
id?:
displayName?:
icon?:
description?:
readOnly?:
PropertiesProperties的直接链接
id:
name:
provider:
readOnly:
MethodsMethods的直接链接
AzureBlobFilesystem implements the WorkspaceFilesystem interface, providing all standard filesystem methods:
readFile(path, options?)- Read file contentswriteFile(path, content, options?)- Write content to a fileappendFile(path, content)- Append content to a filedeleteFile(path, options?)- Delete a filecopyFile(src, dest, options?)- Copy a filemoveFile(src, dest, options?)- Move or rename a filemkdir(path, options?)- Create a directoryrmdir(path, options?)- Remove a directoryreaddir(path, options?)- List directory contentsexists(path)- Check if a path existsstat(path)- Get file or directory metadata
init()init的直接链接
Initialize the filesystem. Verifies container access and credentials.
await filesystem.init()
getInfo()getinfo的直接链接
Returns metadata about this filesystem instance.
const info = filesystem.getInfo()
// { id: '...', name: 'AzureBlobFilesystem', provider: 'azure-blob', status: 'ready' }
getContainer()getcontainer的直接链接
Returns the underlying Azure Blob Storage ContainerClient.
const container = await filesystem.getContainer()
getMountConfig()getmountconfig的直接链接
Returns the mount configuration for sandbox providers that support Azure Blob filesystem mounts.
const config = filesystem.getMountConfig()
// { type: 'azure-blob', container: 'my-container', ... }
Azure Blob sandbox mounting depends on sandbox support for azure-blob mount configs. Use filesystem for direct workspace file operations when your sandbox provider doesn't support Azure Blob mounts.