def create_account(storage_client, resource_group_name, name, location): future = storage_client.storage_accounts.create( resource_group_name, name, StorageAccountCreateParameters(sku=Sku(SkuName.standard_ragrs), kind=Kind.storage, location=location)) future.result() return get_account(storage_client, resource_group_name, name)
def create_storage_account(self, location, resource_group_name, account_name): try: return self.storage_client.storage_accounts.begin_create( resource_group_name, account_name, StorageAccountCreateParameters( sku=Sku(name=SkuName.standard_ragrs), kind=Kind.storage, location=location, enable_https_traffic_only=True, ), ) except ClientException as exc: raise AzureBackendError(exc)
def create_storage_account(credentials, subscription_id, **kwargs): """ Create a Storage account :param credentials: msrestazure.azure_active_directory.AdalAuthentication :param subscription_id: str :param **resource_group: str :param **storage_account: str :param **region: str """ storage_management_client = StorageManagementClient(credentials, subscription_id) storage_account = storage_management_client.storage_accounts.create( resource_group_name=kwargs.get("resource_group", DefaultSettings.resource_group), account_name=kwargs.get("storage_account", DefaultSettings.storage_account), parameters=StorageAccountCreateParameters( sku=Sku(SkuName.standard_lrs), kind=Kind.storage, location=kwargs.get('region', DefaultSettings.region))) return storage_account.result().id
def create_storage(resource_group: str, account_name: str, location: str) -> str: params = StorageAccountCreateParameters( sku=Sku(name=SkuName.premium_lrs), kind=Kind.block_blob_storage, location=location, tags={"storage_type": "corpus"}, access_tier=AccessTier.hot, allow_blob_public_access=False, minimum_tls_version="TLS1_2", ) client = get_client_from_cli_profile(StorageManagementClient) account = client.storage_accounts.create(resource_group, account_name, params).result() if account.provisioning_state != "Succeeded": raise Exception( "storage account creation failed: %s", json.dumps(account.as_dict(), indent=4, sort_keys=True), ) return account.id
def createStorageAccount(self, resourceGroupName, storageAccountName, resourceGroupLocation, subscriptionId): logging.info("Creating new Storage Account with Name: " + storageAccountName + " and Location: " + resourceGroupLocation) storageClient = self.getStorageManagementClient(subscriptionId) check = self.__checkStorageAccountExists(storageAccountName, storageClient) if check: logging.info("Storage Account with Name: " + storageAccountName + " and Location: " + resourceGroupLocation + " already exists.") return self.getStorageAccount(resourceGroupName, storageAccountName, subscriptionId) storage_async_operation = storageClient.storage_accounts.create( resourceGroupName, storageAccountName, StorageAccountCreateParameters( sku=Sku(name=SkuName.standard_lrs), kind=Kind.storage_v2, location=resourceGroupLocation, supportsHttpsTrafficOnly=True ) ) storageAccount = storage_async_operation.result() logging.info("Storage account created successfully with Name: " + storageAccountName + " and Location: " + resourceGroupLocation) return storageAccount