SeaDude
SeaDude

Reputation: 4405

Azure Python SDK: BlobServiceClient.get_container_client returning TypeError?

This is baffling me. I must be missing something obvious. Just trying to get a ContainerClient from a BlobServiceClient.

Example:

import os
import logging
from azure.storage.blob import BlobServiceClient, BlobClient

conn_string = "connection-string-here"
cont_name = "cont-test"

blob_svc_client = BlobServiceClient.from_connection_string(conn_string)

blob_cont_client = BlobServiceClient.get_container_client(cont_name)

Returns:

C:\Users\user\Desktop>python myProgram.py
Traceback (most recent call last):
  File "C:\Users\user\Desktop\myProgram.py", line 11, in <module>
    blob_cont_client = BlobServiceClient.get_container_client(cont_name)
TypeError: get_container_client() missing 1 required positional argument: 'container'

Why is this happening?

Upvotes: 0

Views: 5683

Answers (1)

SaiKarri-MT
SaiKarri-MT

Reputation: 1301

I have modified your code by adding the extension to blob_svc_client with get_container_client variable. Below is the updated code:

import os
import logging
from azure.storage.blob import BlobServiceClient, BlobClient

conn_string = "connection-string-here"
cont_name = "cont-test"

blob_svc_client = BlobServiceClient.from_connection_string(conn_string)

blob_cont_client = blob_svc_client.get_container_client(cont_name)

I have reproduced your error as below:

Error

Below is the fixed screenshot:

enter image description here

Upvotes: 2

Related Questions