AppSec & Pentest
CloudSec
CloudSec
  • Sandboxes, Containers, Virtualization
    • Какие бывают
    • Kubernetes
      • About
      • Tools
        • kubectl
        • minikube
        • helm
        • tiller
        • Others
      • Components
      • Concepts
      • Security
      • Learning
      • Conferences & Events
    • Container Runtime Interface (CRI)
      • containerd
      • CRI-0
      • Podman
      • Colima
      • Docker
        • About
        • CLI
        • Dockerfile
        • docker compose
        • Registry
        • Testcontainers
        • [Def] Security
        • [Off] Security
    • Red Hat OpenShift Container Platform (OCP)
      • About
      • OCP Components
        • Platform services
        • Application services
        • Developer services
        • OpenShift Kubernetes Engine
      • Security
        • Container Security
        • Podman
        • Kubernetes Security
        • Securing Platform Services
        • Vulnerabilities
        • CIS
    • VMWare
      • Workspace ONE Access
      • Workspace One UEM SSRF (AirWatch)
      • vSphere
      • vCenter
      • Learn
      • Horizon Security Server
      • VMWare log4j
    • Tools
      • Build container image inside containers
      • Moby
      • Security
  • Cloud
    • Google Cloud Platform (GCP)
      • GCP Components
      • GCP CLI
      • Security
        • Get access to GCP via service-account [json]
        • PrivEsc
        • Papers
      • Courses & Certifications
    • Azure
      • Azure Start
      • Azure CLI
      • Компоненты и механизмы
        • Azure Storage BLOB
        • Подписанные URL (SAS)
      • Papers and Resources
      • Azure Security Center
      • Tools
    • AWS
      • AWS Intro
      • AWS Basics
      • AWS Components
        • Computing
        • Storage
        • Messaging
        • Serverless
        • Business Productivity
        • Network and Content Delivery
        • Mobile
        • Databases
      • AWS Testing
      • Basic Work: Examples
        • AWS Cli
        • AWS SES
        • S3 Bucket
      • Security
        • Enumeration
        • AWS Lambda
        • Разные примеры
        • Learn Materials
      • Books & Papers
      • Courses & Certifications
    • Yandex Cloud
      • YC CLI
      • YC API
      • Cloud Organization
      • VM
        • Cloud Computing
        • Virtual Private Cloud (VPC)
        • Network Load Balancer
      • Data Platform
        • Definitions
        • Как выбрать БД
        • Реляционные БД
        • Нереляционные БД
        • Object Storage and S3
      • Yandex k8s
      • Serverless
      • Security
      • Billing
    • Another platforms
    • OpenStack
    • Tools
      • Tool list
      • Packer
      • Terraform
        • Intro
        • Getting started
        • Configuration
          • Basic
            • Terraform Block
            • Providers
            • Resources
            • Variables
            • Outputs
            • Functions
          • Modules
        • Security
        • Papers
    • Papers
Powered by GitBook
On this page
  • Python
  • Install
  • Example

Was this helpful?

  1. Cloud
  2. Azure
  3. Компоненты и механизмы

Azure Storage BLOB

PreviousКомпоненты и механизмыNextПодписанные URL (SAS)

Last updated 2 years ago

Was this helpful?

Хранение больших двоичных файлов

Python

Install

pip install azure-storage-blob

Example

Используйте следующие классы Python для взаимодействия с ресурсами.

  • . Класс BlobServiceClient позволяет управлять ресурсами службы хранилища Azure и контейнерами больших двоичных объектов.

  • . Класс ContainerClient позволяет управлять контейнерами службы хранилища Azure и содержащимися в них большими двоичными объектами.

  • . Класс BlobClient позволяет управлять большими двоичными объектами службы хранилища Azure.

import os, uuid
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient, __version__


def list_blobs(blob_service_client, container: str):
    container_client = blob_service_client.get_container_client(container)

    print(f"\nListing blobs for container '{container}'...")

    # List the blobs in the container
    blob_list = container_client.list_blobs()
    for blob in blob_list:
        print("\t" + blob.name)

def blob_url():
    blob_client = BlobClient.from_connection_string(
        AZURE_STORAGE_CONNECTION_STRING, container_name="dev", blob_name="test.txt")
    print(blob_client.url)

try:
    print("Azure Blob Storage v" + __version__ + " - Python quickstart sample")

    ACCOUNT_KEY = "ySUF4d***29PA=="
    AZURE_STORAGE_CONNECTION_STRING = "DefaultEndpointsProtocol=https;AccountName=someaccountname;AccountKey=ySUF4d***29PA==;EndpointSuffix=core.windows.net"
    # Quick start code goes here

    # Create the BlobServiceClient object which will be used to create a container client
    blob_service_client = BlobServiceClient.from_connection_string(AZURE_STORAGE_CONNECTION_STRING)

    account_info = blob_service_client.get_account_information()
    print('Using Storage SKU: {}'.format(account_info['sku_name']))
    print('Using Account kind: {}'.format(account_info['account_kind']))
    # print(account_info)

    for container_name in ["dev", "beta", "production"]:
        # enum blobs
        list_blobs(blob_service_client, container_name)

except Exception as ex:
    print('Exception:')
    print(ex)

Залить файл:

blob_client = blob_service_client.get_blob_client(container="dev", blob="test.txt")

with open("test2.txt", "rb") as file:
    blob_client.upload_blob(file)
BlobServiceClient
ContainerClient
BlobClient