> For the complete documentation index, see [llms.txt](https://docs.roboflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboflow.com/roboflow/roboflow-hi/datasets/adding-data/upload-data-from-aws-gcp-and-azure/azure-blob-storage.md).

# Azure Blob Storage

Azure Blob Storage में image data storage को संभालते समय और Roboflow पर upload करते समय, आपके पास आम तौर पर दो विकल्प होते हैं: signed URLs का उपयोग करना, या images को locally manually download करना (Azure CLI के माध्यम से) ताकि उन्हें local रूप से upload किया जा सके। इन तरीकों के बीच चुनाव data processing और management के लिए आपकी विशिष्ट ज़रूरतों पर निर्भर करता है।

* **Signed URLs**: यह तरीका विशेष रूप से तब फायदेमंद है जब आप images को अपनी local machine पर डाउनलोड करने से जुड़ा अतिरिक्त चरण और समय की खपत से बचना चाहते हैं। एक signed URL के साथ, आप image data को Azure Blob Storage से सीधे Roboflow API पर upload कर सकते हैं, बिना इसे कभी locally store किए। इससे processing तेज़ होती है और आपके local system पर कम load पड़ता है।
* **स्थानीय CLI**: कुछ ऐसे परिदृश्य हो सकते हैं जहाँ आप पहले images को अपने local environment में डाउनलोड करना पसंद करेंगे। उदाहरण के लिए, यदि आपको Roboflow पर upload करने से पहले images को preprocess करना है या manually जाँचना है, तो local copies होना उपयोगी होगा।

सही method का चयन आपके विशिष्ट use-case requirements पर निर्भर करेगा, जैसे data transfer की speed, preprocessing की आवश्यकता, या images का manual inspection।

### Azure Connection String

Storage Account बनाने के बाद, आप Azure portal में "Security + networking" के अंतर्गत "Access keys" section में access keys या connection string पा सकते हैं। इन credentials का उपयोग आपके application को authenticate करने के लिए किया जाता है।

### विकल्प 1: Signed URL के माध्यम से अपलोड करें:

आप Python में Azure SDK द्वारा Azure Blob Storage में अपनी images के लिए signed URLs generate कर सकते हैं।

```python
def get_blob_sas_url(blob_service_client, container_name: str, blob_name: str) -> str:
    """Azure Blob के लिए एक SAS URL जनरेट करें।"""
    from azure.storage.blob import generate_blob_sas, BlobSasPermissions
    from datetime import datetime, timedelta

    sas_token = generate_blob_sas(
        blob_service_client.account_name,
        container_name,
        blob_name,
        account_key=blob_service_client.credential.account_key,
        permission=BlobSasPermissions(read=True),
        expiry=datetime.utcnow() + timedelta(hours=1)
    )
    
    blob_url = f"https://{blob_service_client.account_name}.blob.core.windows.net/{container_name}/{blob_name}?{sas_token}"
    return blob_url
```

ऊपर दिए गए code snippet में, आपको blob service client, container name, और blob name की आवश्यकता होती है। image का signed URL generate किया जाता है और वापस लौटाया जाता है।

इसके आधार पर, हम एक complete solution बना सकते हैं जो Azure Blob Storage में उपलब्ध सभी objects को खींचता है, और फिर उन्हें API के माध्यम से Roboflow पर upload करता है। इस solution की रूपरेखा नीचे देखी जा सकती है:

```python
from azure.storage.blob import BlobServiceClient
import requests
import urllib.parse

# ************* इन variables को सेट करें *************
AZURE_CONNECTION_STRING = "YOUR_AZURE_CONNECTION_STRING"
AZURE_CONTAINER_NAME = "YOUR_AZURE_CONTAINER_NAME"
ROBOFLOW_API_KEY = "YOUR_ROBOFLOW_API_KEY"
ROBOFLOW_PROJECT_NAME = "YOUR_ROBOFLOW_PROJECT_NAME"
# ***********************************************

def get_blob_sas_url(blob_service_client, container_name: str, blob_name: str) -> str:
    """Azure Blob के लिए एक SAS URL जनरेट करें।"""
    from azure.storage.blob import generate_blob_sas, BlobSasPermissions
    from datetime import datetime, timedelta

    sas_token = generate_blob_sas(
        blob_service_client.account_name,
        container_name,
        blob_name,
        account_key=blob_service_client.credential.account_key,
        permission=BlobSasPermissions(read=True),
        expiry=datetime.utcnow() + timedelta(hours=1)
    )
    
    blob_url = f"https://{blob_service_client.account_name}.blob.core.windows.net/{container_name}/{blob_name}?{sas_token}"
    return blob_url

def get_azure_blob_objects(container_name: str) -> list:
    """दिए गए Azure Blob container में blob names की सूची प्राप्त करें।"""
    blob_service_client = BlobServiceClient.from_connection_string(AZURE_CONNECTION_STRING)
    container_client = blob_service_client.get_container_client(container_name)
    
    blobs = []
    blob_list = container_client.list_blobs()
    for blob in blob_list:
        blobs.append(blob.name)
    return blobs

def upload_to_roboflow(api_key: str, project_name: str, presigned_url: str, img_name='', split="train"):
    """Roboflow में एक image upload करें।"""
    API_URL = "https://api.roboflow.com"
    यदि img_name == '':
        img_name = presigned_url.split("/")[-1]

    upload_url = "".join([
        API_URL + "/dataset/" + project_name + "/upload",
        "?api_key=" + api_key,
        "&name=" + img_name,
        "&split=" + split,
        "&image=" + urllib.parse.quote_plus(presigned_url),
    ])
    response = requests.post(upload_url)

    # response code जाँचें
    if response.status_code == 200:
        print(f"{img_name} को {project_name} में सफलतापूर्वक upload किया गया")
        return True
    else:
        print(f"{img_name} को upload करने में विफल। Error: {response.content.decode('utf-8')}")
        return False

if __name__ == "__main__":
    # उपलब्ध blobs की सूची प्राप्त करें
    available_blobs = get_azure_blob_objects(AZURE_CONTAINER_NAME)
    
    # वैकल्पिक: यहाँ blobs को फ़िल्टर करें
    # उदाहरण के लिए, available_blobs = [blob for blob in available_blobs if "some_condition"]
    
    # Azure Blob Service Client को initialize करें
    blob_service_client = BlobServiceClient.from_connection_string(AZURE_CONNECTION_STRING)
    
    # blobs को Roboflow पर upload करें
    for blob in available_blobs:
        blob_url = get_blob_sas_url(blob_service_client, AZURE_CONTAINER_NAME, blob)
        upload_to_roboflow(ROBOFLOW_API_KEY, ROBOFLOW_PROJECT_NAME, blob_url)

```

### विकल्प 2: Azure से डेटा स्थानीय रूप से डाउनलोड करें

सबसे पहले, `azcopy` command line utility इंस्टॉल करें। यह utility आपको Azure Storage से files और folders डाउनलोड करने देती है। फिर, एक [Shared Access Signature](https://learn.microsoft.com/en-us/azure/storage/common/storage-sas-overview) token का उपयोग करके अपने Azure account के साथ authenticate करें। आप इसके बारे में और जान सकते हैं [SAS token कैसे retrieve करें](https://learn.microsoft.com/en-us/azure/storage/common/storage-sas-overview) azcopy documentation में।

जब आपके पास `azcopy` set up हो जाए, तो किसी file या folder को डाउनलोड करने के लिए निम्न command चलाएँ:

```bash
azcopy copy "C:\\local\\path" <sas-token> --recursive=true
```

बदलें `C:\\local\\path` को उस folder या file के path से बदलें जिसे आप डाउनलोड करना चाहते हैं। `<sas-token>` value को authentication के लिए SAS token से बदलें। यदि आप files और folders को recursively डाउनलोड करना चाहते हैं, तो ऊपर जैसा `--recursive=true` argument निर्दिष्ट करें। अन्यथा, इस argument को हटा दें।

### Roboflow में डेटा अपलोड करें

अब जब हमने data डाउनलोड कर लिया है, तो हम इसे Roboflow में या तो [Upload Web Interface](/roboflow/roboflow-hi/datasets/adding-data.md#upload-data-with-the-web-application) या [Roboflow CLI](/roboflow/roboflow-hi/datasets/adding-data.md#upload-datasets-with-the-command-line).

### यह भी देखें

* [Roboflow project ID प्राप्त करें](https://docs.roboflow.com/api-reference/workspace-and-project-ids)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.roboflow.com/roboflow/roboflow-hi/datasets/adding-data/upload-data-from-aws-gcp-and-azure/azure-blob-storage.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
