We want customers to specify their own place to have their database, and to store the machine learning file.
The database connection is clear: just specify the connection string to the Azure database, and you're ready to go (well, use pyodbc)
Azure now has many services to store something, and it is not immediately clear which one to use for this purpose.
After looking around, it seemed that the Workspace I created earlier is also a blob storage. Here you can find the accountname to use, and accesskey:
So after installing the correct packages, the code below worked.
pip install azure-storage-blob azure-mgmt-storage
from azure.storage.blob import BlockBlobService, PublicAccess
blob_service = BlockBlobService('[your account name]','[your access key]')
blob_service.create_container(
'mycontainername',
public_access=PublicAccess.Blob
)
blob_service.create_blob_from_bytes(
'mycontainername',
'myblobname',
b'hello from my python file'
)
print(blob_service.make_blob_url('mycontainername', 'myblobname'))The example code from here shows how to download to file
blob_service = BlockBlobService('[your account name]','[your access key]')
blob_service.create_container(
'mycontainername',
public_access=PublicAccess.Blob
)
blob_service.create_blob_from_bytes(
'mycontainername',
'myblobname',
b'hello from my python file'
)
print(blob_service.make_blob_url('mycontainername', 'myblobname'))
block_blob_service.get_blob_to_path(container_name, local_file_name, full_path_to_file2)
and upload:
block_blob_service.create_blob_from_path(container_name, local_file_name, full_path_to_file)
Geen opmerkingen:
Een reactie posten