VSC ‐ Send data to blob storage from instance (alternative to SGW) - SanjeevOCI/Study GitHub Wiki
SanjeevOCI: Send data to blob storage from instance (alternative to SGW)
GitHub Copilot: To send data directly to Azure Blob Storage from your instance (as an alternative to using a Storage Gateway), you can use the Azure Blob Storage SDKs or REST API. Here’s a simple example using Python and the Azure SDK:
# Install the Azure Blob Storage SDK first:
# pip install azure-storage-blob
from azure.storage.blob import BlobServiceClient
# Replace with your connection string and container/blob names
connection_string = "DefaultEndpointsProtocol=https;AccountName=your_account;AccountKey=your_key;EndpointSuffix=core.windows.net"
container_name = "your-container"
blob_name = "your-blob.txt"
local_file_path = "path/to/local/file.txt"
# Create the BlobServiceClient object
blob_service_client = BlobServiceClient.from_connection_string(connection_string)
# Get a client to interact with the container
container_client = blob_service_client.get_container_client(container_name)
# Upload the file
with open(local_file_path, "rb") as data:
container_client.upload_blob(name=blob_name, data=data, overwrite=True)
print("Upload complete.")
Alternatives:
- Use the Azure CLI:
az storage blob upload --account-name <account> --container-name <container> --name <blob> --file <file-path> --account-key <key>
- Use PowerShell:
Set-AzStorageBlobContent -File <file-path> -Container <container> -Blob <blob> -Context $ctx
Summary:
You can send data directly to Azure Blob Storage from your instance using SDKs, CLI, or REST API, without needing a Storage Gateway.