Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating shared access signature for container to upload blobs #651

Closed
prashanthmadi opened this issue Jun 24, 2016 · 4 comments
Closed

Comments

@prashanthmadi
Copy link

prashanthmadi commented Jun 24, 2016

Could you provide a sample to create shared access signature with new version of python SDK.

i'm trying to use my old py code and was getting below error

 from azure.storage import AccessPolicy
 from azure.storage.sharedaccesssignature import (
 SharedAccessPolicy,
 SharedAccessSignature,
 )

 DEV_STORAGE_ACCOUNT_NAME ="xxxxx"
 DEV_STORAGE_ACCOUNT_KEY ="xxxxx"
 CONTAINER_NAME='xxxxx'
 STORAGE_URL = 'xxxxx'

 def generate_signature_blob(dev_storage_account_name,dev_storage_account_key,container_name):
 sas = SharedAccessSignature(account_name=dev_storage_account_name,account_key=dev_storage_account_key)
 accss_plcy = AccessPolicy()
 accss_plcy.expiry = '2016-10-12'
 accss_plcy.permission = 'w'
 sap = SharedAccessPolicy(accss_plcy)
 sasToken = sas.generate_signed_query_string(container_name,'container',sap)
 return sas._convert_query_string(sasToken).replace("container","c")

Error :

Traceback (most recent call last):
  File "test.py", line 5, in <module>
    from azure.storage.sharedaccesssignature import
ImportError: cannot import name SharedAccessPolicy
@lmazuel
Copy link
Member

lmazuel commented Jun 24, 2016

Hi @prashanthmadi

Issue about Storage runtime have to be submitted here:
https://github.com/Azure/azure-storage-python

You will also find a samples folder to help you:
https://github.com/Azure/azure-storage-python/tree/master/samples

@lmazuel lmazuel closed this as completed Jun 24, 2016
@prashanthmadi
Copy link
Author

Thanks Laurent.

Below link has a sample for SAS
https://github.com/Azure/azure-storage-python/blob/master/samples/blob/sas_usage.py

@prashanthmadi
Copy link
Author

@salmanchauhan
Copy link

@prashanthmadi @lmazuel @xiafu-msft
I am using following code to generate container sas and access it further,
sas_token = generate_container_sas(
container_name=container_name,
permission=ContainerSasPermissions(read=True,list=True,write=True),
expiry=datetime.utcnow() + timedelta(days=1),
account_name = account_name,
account_key=account_key,
start=datetime.utcnow(),
)
print(sas_token)

but the sas token later i am using to access a blob I am getting 403.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants