Update RTD front page storage example
@@ -21,7 +21,7 @@ This example shows:
from azure.mgmt.resource import ResourceManagementClient
from azure.mgmt.storage import StorageManagementClient
from azure.storage import CloudStorageAccount
- from azure.storage.blob.models import ContentSettings
+ from azure.storage.blob.models import ContentSettings, PublicAccess
credentials = UserPassCredentials('user@domain.com', 'my_smart_password')
subscription_id = '33333333-3333-3333-3333-333333333333'
@@ -29,39 +29,48 @@ This example shows:
resource_client = ResourceManagementClient(credentials, subscription_id)
storage_client = StorageManagementClient(credentials, subscription_id)
+ resource_group_name = 'my_resource_group'
+ storage_account_name = 'myuniquestorageaccount'
+
resource_client.resource_groups.create_or_update(
- 'my_resource_group',
+ resource_group_name,
{
'location':'westus'
}
)
async_create = storage_client.storage_accounts.create(
- 'my_resource_group',
- 'my_storage_account',
+ resource_group_name,
+ storage_account_name,
{
'location':'westus',
- 'account_type':'Standard_LRS'
+ 'kind':'storage',
+ 'sku': {
+ 'name':'standard_ragrs'
+ }
}
)
async_create.wait()
- storage_keys = storage_client.storage_accounts.list_keys('my_resource_group', 'my_storage_account')
+ storage_keys = storage_client.storage_accounts.list_keys(resource_group_name, storage_account_name)
storage_keys = {v.key_name: v.value for v in storage_keys.keys}
- storage_client = CloudStorageAccount('my_storage_account', storage_keys['key1'])
+ storage_client = CloudStorageAccount(storage_account_name, storage_keys['key1'])
blob_service = storage_client.create_block_blob_service()
- blob_service.create_container('my_container_name')
+ blob_service.create_container(
+ 'mycontainername',
+ public_access=PublicAccess.Blob
+ )
blob_service.create_blob_from_bytes(
- 'my_container_name',
- 'my_blob_name',
+ 'mycontainername',
+ 'myblobname',
b'<center><h1>Hello World!</h1></center>',
content_settings=ContentSettings('text/html')
)
- print(blob_service.make_blob_url('my_container_name', 'my_blob_name'))
+ print(blob_service.make_blob_url('mycontainername', 'myblobname'))
Installation
