Azure Blob
With this integration you can store and access data into Azure Blob Storage.
Official Websitehttps://azure.microsoft.com/en-us/services/storage/blobs/
TagsFilesSaas
- JavaScript
- Python
Documentationhttps://docs.microsoft.com/en-gb/javascript/api/@azure/storage-blob/?view=azure-node-latest
NodeJS packagehttps://www.npmjs.com/package/@azure/storage-blob
Version12.17.0
Credential configuration
To obtain the connection string to Azure Blob, navigate to the main page of the Storage Account you need to access. Next, go to the Access keys section, found in the sidebar inside Security + Networking menu section. In Access keys section you'll find and can copy the connection string to fill in this credential form.
Connection string format example:
DefaultEndpointsProtocol=[http|https];AccountName=myAccountName;AccountKey=myAccountKey
In the extra options field, you can include any of the parameters listed
here in the StoragePipelineOptions
object.
Here is an example of a filled credential configuration form in YepCode:
Azure Blob Snippets available in YepCode editor
note
The title is the triggering text for YepCode to autocomplete the script.
- JavaScript
- Python
Integration
New integration from credential
const azureBlobClient = yepcode.integration.azureBlob("credential-slug");
New integration from plain authentication data
const { BlobServiceClient } = require("@azure/storage-blob");
const azureBlobClient = BlobServiceClient.fromConnectionString("your_connection_string");
Create Container
Create container
const containerClient = azureBlobClient.getContainerClient("container-name");
const createContainerResponse = await containerClient.create();
console.log(
`Create container successfully`,
createContainerResponse.requestId
);
List Containers
List containers
let containers = azureBlobClient.listContainers();
for await (const container of containers) {
console.log(`Found container: ${container.name}`);
}
Delete Container
Delete container
const containerClient = azureBlobClient.getContainerClient("container-name");
await containerClient.delete();
console.log(`Deleted container!`);
List Blobs
List blobs
const containerClient = azureBlobClient.getContainerClient("container-name");
let blobs = containerClient.listBlobsFlat();
for await (const blob of blobs) {
console.log(`Found blob: ${blob.name}`);
}
Create Blob from String
Create blob from string
const containerClient = azureBlobClient.getContainerClient("container-name");
const blockBlobClient = containerClient.getBlockBlobClient("blob-name");
const content = "content";
const uploadBlobResponse = await blockBlobClient.upload(
content,
content.length
);
console.log(
`Created block blob successfully`,
uploadBlobResponse.requestId
);
Create Blob from Stream
Create blob from stream
const containerClient = azureBlobClient.getContainerClient("container-name");
const blockBlobClient = containerClient.getBlockBlobClient("blob-name");
await blockBlobClient.uploadStream(stream);
console.log(`Created block blob successfully`);
Read Blob Content
Read blob content
const containerClient = azureBlobClient.getContainerClient("container-name");
const blobClient = containerClient.getBlobClient("blob-name");
const downloadBlockBlobResponse = await blobClient.download();
const blobStream = downloadBlockBlobResponse.readableStreamBody;
blobStream.on("data", (data) => {
console.log(Buffer.from(data).toString("utf8"));
});
blobStream.on("end", () => {
console.log("All blob content shown");
});
blobStream.on("error", (error) => {
console.log(error);
});
Integration
New integration from credential
azure_blob_client = yepcode.integration.azure_blob("credential-slug")
New integration from plain authentication data
from azure.storage.blob import BlobServiceClient
azure_blob_client = BlobServiceClient.from_connection_string(conn_str="your_connection_string");
Create Container
Create container
container_client = azure_blob_client.get_container_client("container-name")
create_container_response = container_client.create_container()
print('Create container successfully', create_container_response)
List Containers
List containers
containers = azure_blob_client.list_containers()
for container in containers:
print(f"Found container: {container['name']}")
Delete container
Delete container
container_client = azure_blob_client.get_container_client("container-name")
container_client.delete_container()
print('Deleted container!')
List Blobs
List blobs
container_client = azure_blob_client.get_container_client("container-name")
blobs = container_client.list_blobs()
for blob in blobs:
print(f"Found blob: {blob.name}")
Create Blob from String
Create blob from string
container_client = azure_blob_client.get_container_client("container-name")
block_blob_client = container_client.get_blob_client("blob-name")
content = "content"
upload_blob_response = block_blob_client.upload_blob(
content,
len(content)
)
print(f"Created block blob successfully: {upload_blob_response})
Create Blob from Stream
Create blob from stream
container_client = azure_blob_client.get_container_client("container-name")
block_blob_client = container_client.get_blob_client("blob-name")
block_blob_client.upload_blob(stream)
print("Created block blob successfully")
Read Blob Content
Read blob content
container_client = azure_blob_client.get_container_client("container-name")
blob_client = container_client.get_blob_client("blob-name")
download_block_response = blob_client.download_blob(encoding='UTF-8')
data = download_block_response.readall()
print(f"Blob contents: {data}")