Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
aa33a8c
init codegen for datashare
fengzhou-msft Mar 20, 2020
254f368
add manual code
fengzhou-msft Mar 23, 2020
736f686
modify help
fengzhou-msft Mar 24, 2020
7af1a13
modify datashare account
fengzhou-msft Mar 30, 2020
ecd3036
modify params
fengzhou-msft Mar 31, 2020
86e4bbd
update metadata
fengzhou-msft Apr 3, 2020
f9788ef
add init files
fengzhou-msft Apr 4, 2020
b891431
add integration tests
fengzhou-msft Apr 6, 2020
23caf12
full tests for provider and consumer
fengzhou-msft Apr 7, 2020
77b93cb
Merge remote-tracking branch 'upstream/master' into datashare
fengzhou-msft Apr 8, 2020
47fd90d
refactor command interface
fengzhou-msft Apr 9, 2020
2fedea2
add README
fengzhou-msft Apr 10, 2020
306793f
add wait command for datashare consumer share-subscription synchroniz…
fengzhou-msft Apr 12, 2020
f74f671
Update README.md
fengzhou-msft Apr 14, 2020
217ef67
fix location
fengzhou-msft Apr 14, 2020
ab2b208
modify help
fengzhou-msft Apr 18, 2020
aa7cd57
remove --identity
fengzhou-msft Apr 21, 2020
d1073be
flattern synchronization setting
fengzhou-msft Apr 21, 2020
6b20902
remove some generated file
fengzhou-msft Apr 21, 2020
9fa2a5c
Merge branch 'master' into datashare
fengzhou-msft Apr 21, 2020
6600ebb
removed unused file
fengzhou-msft Apr 22, 2020
251fb01
Merge branch 'datashare' of github.com:fengzhou-msft/azure-cli-extens…
fengzhou-msft Apr 22, 2020
d82d28d
update readme
fengzhou-msft Apr 23, 2020
388e336
modify trigger
fengzhou-msft Apr 23, 2020
e77229f
update recordings
fengzhou-msft Apr 23, 2020
8ad724e
remove unsed files
fengzhou-msft Apr 23, 2020
3178a95
Merge branch 'datashare' of github.com:fengzhou-msft/azure-cli-extens…
fengzhou-msft Apr 23, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,5 @@
/src/hpc-cache/ @qianwens

/src/account/ @zikalino

/src/datashare/ @fengzhou-msft
8 changes: 8 additions & 0 deletions src/datashare/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. :changelog:

Release History
===============

0.1.0
++++++
* Initial release.
201 changes: 201 additions & 0 deletions src/datashare/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
# Azure CLI datashare Extension #
This package is for the 'datashare' extension, i.e. 'az datashare'. More info on what is [Data Share](https://docs.microsoft.com/azure/data-share/).

### How to use ###
Install this extension using the below CLI command
```
az extension add --name datashare
```

Register DataShare Resource Provider for your default susbcription.
```
az provider register -n "Microsoft.DataShare"
```

### Included Features
#### Datashare Account Management
*Examples:*

##### Create a Datashare Account

```
az datashare account create \
--location "West US 2" \
--tags tag1=Red tag2=White \
--name "cli_test_account" \
--resource-group "datashare_provider_rg"
```

##### Wait for the Datashare Account to be provisioned
```
az datashare account wait \
--name "cli_test_account" \
--resource-group "datashare_provider_rg" \
--created
```

#### Datashare Resource Management for a Provider
*Examples:*

##### Create a Datashare
```
az datashare create \
--account-name "cli_test_account" \
--resource-group "datashare_provider_rg" \
--description "share description" \
--share-kind "CopyBased" \
--terms "Confidential" \
--name "cli_test_share"
```

##### Create a Data Set
```
az datashare dataset create \
--account-name "cli_test_account" \
--name "cli_test_data_set" \
--resource-group "datashare_provider_rg" \
--share-name "cli_test_share" \
--dataset "{\"container_name\":\"mycontainer\",\"storage_account_name\":\"mysa\",\"kind\":\"Container\"}"
```

Please make sure the datashare account has the right permission of the data source when creating a data set upon it.
For instance, you can use `az datashare account show` to get 'identity.principalId' of the account, then assign the right role to it.
```
az role assignment create \
--role "Storage Blob Data Reader" \
--assignee-object-id {DatashareAccountPrincipalId} \
--assignee-principal-type ServicePrincipal \
--scope {StorageAccountId}
```

##### Create a Synchronization Setting
```
az datashare synchronization-setting create \
--account-name cli_test_account \
--resource-group datashare_provider_rg \
--share-name cli_test_share \
--name cli_test_synchronization_setting \
--recurrence-interval Day \
--synchronization-time "2020-04-05 10:50:00 +00:00" \
--kind ScheduleBased
```

##### List Synchronization History
```
az datashare synchronization list \
--account-name "cli_test_account" \
--resource-group "datashare_provider_rg" \
--share-name "cli_test_share"
```

##### Create a Datashare Invitation
```
az datashare invitation create \
--account-name "cli_test_account" \
--target-email "myname@microsoft.com" \
--name "cli_test_invitation" \
--resource-group "datashare_provider_rg" \
--share-name "cli_test_share"
```

##### List Share Subscriptions
```
az datashare provider-share-subscription list \
--account-name "cli_test_account" \
--resource-group "datashare_provider_rg" \
--share-name "cli_test_share"
```
Share subscriptions are created by Datashare consumers when they accept invitations.

##### Revoke Datashare for a Share Subscription
```
az datashare provider-share-subscription revoke \
--account-name "cli_test_account" \
--share-subscription "{ProviderShareSubscriptionObjectId}" \
--resource-group "datashare_provider_rg" \
--share-name "cli_test_share"
```

##### Reinstate Datashare for a Share Subscription
```
az datashare provider-share-subscription reinstate \
--account-name "cli_test_account" \
--share-subscription "{ProviderShareSubscriptionObjectId}" \
--resource-group "datashare_provider_rg" \
--share-name "cli_test_share"
```

#### Datashare Resource Management for a Consumer
*Examples:*

##### List received Invitations
```
az datashare consumer invitation list
```

##### Create a Share Subscription from an Invitation
```
az datashare consumer share-subscription create \
--account-name "cli_test_consumer_account" \
--resource-group "datashare_consumer_rg" \
--invitation-id "{InvitationId1}" \
--source-share-location "sourceShareLocation" \
--name "cli_test_share_subscription"
```

##### List Source Data Sets in the Share Subscription
```
az datashare consumer share-subscription list-source-dataset \
--account-name "cli_test_consumer_account" \
--resource-group "datashare_consumer_rg" \
--share-subscription-name "cli_test_share_subscription"
```

##### Create a Data Set Mapping of the Source Data Set
```
az datashare consumer dataset-mapping create \
--account-name "cli_test_consumer_account" \
--name "cli_test_data_set_mapping" \
--resource-group "datashare_consumer_rg" \
--share-subscription-name "cli_test_share_subscription" \
--mapping "{\"data_set_id\":\"2036a39f-add6-4347-9c82-a424dfaf4e8d\", \
\"container_name\":\"newcontainer\", \"storage_account_name\":\"consumersa\", \
\"kind\":\"BlobFolder\",\"prefix\":\"myprefix\"}"
```
Please make sure the datashare consumer account has the right permission of the data target when creating a data set mapping on it. For instance, you can use `az datashare account show` to get 'identity.principalId' of the account, then assign the right role to it.
```
az role assignment create \
--role "Storage Blob Data Contributor" \
--assignee-object-id "{ConsumerDatashareAccountPrincipalId}" \
--assignee-principal-type ServicePrincipal \
--scope "{ConsumerStorageAccountId}"
```

##### List the synchronization settings of the Source Datashare
```
az datashare consumer share-subscription list-source-share-synchronization-setting \
--account-name "cli_test_consumer_account" \
--resource-group "datashare_consumer_rg" \
--share-subscription-name "cli_test_share_subscription"
```

##### Create a trigger for the Share Subsciption
```
az datashare consumer trigger create \
--account-name "cli_test_consumer_account" \
--resource-group "datashare_consumer_rg" \
--share-subscription-name "cli_test_share_subscription" \
--name "cli_test_trigger" \
--recurrence-interval Day \
--synchronization-time "2020-04-05 10:50:00 +00:00" \
--kind ScheduleBased
```

##### Start a synchronization for the Share Subscription
```
az datashare consumer share-subscription synchronization start \
--account-name "cli_test_consumer_account" \
--resource-group "datashare_consumer_rg" \
--share-subscription-name "cli_test_share_subscription" \
--synchronization-mode "Incremental"
```
49 changes: 49 additions & 0 deletions src/datashare/azext_datashare/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=unused-argument
# pylint: disable=unused-import

from azure.cli.core import AzCommandsLoader
from azext_datashare._help import helps


class DataShareManagementClientCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azext_datashare.generated._client_factory import cf_datashare
datashare_custom = CliCommandType(
operations_tmpl='azext_datashare.manual.custom#{}', # modified
client_factory=cf_datashare)
super(DataShareManagementClientCommandsLoader, self).__init__(cli_ctx=cli_ctx,
custom_command_type=datashare_custom)

def load_command_table(self, args):
try:
from azext_datashare.generated.commands import load_command_table
load_command_table(self, args)
except ImportError:
pass
try:
from azext_datashare.manual.commands import load_command_table as load_command_table_manual
load_command_table_manual(self, args)
except ImportError:
pass
return self.command_table

def load_arguments(self, command):
try:
from azext_datashare.generated._params import load_arguments
load_arguments(self, command)
except ImportError:
pass
try:
from azext_datashare.manual._params import load_arguments as load_arguments_manual
load_arguments_manual(self, command)
except ImportError:
pass


COMMAND_LOADER_CLS = DataShareManagementClientCommandsLoader
16 changes: 16 additions & 0 deletions src/datashare/azext_datashare/_help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

# try:
# from .generated._help import * # noqa: F403
# except ImportError:
# pass

try:
from .manual._help import * # noqa: F403
except ImportError:
pass
16 changes: 16 additions & 0 deletions src/datashare/azext_datashare/_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

try:
from .generated._params import * # noqa: F403
except ImportError:
pass

try:
from .manual._params import * # noqa: F403
except ImportError:
pass
16 changes: 16 additions & 0 deletions src/datashare/azext_datashare/action.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

try:
from .generated.action import * # noqa: F403
except ImportError:
pass

try:
from .manual.action import * # noqa: F403
except ImportError:
pass
4 changes: 4 additions & 0 deletions src/datashare/azext_datashare/azext_metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"azext.isExperimental": true,
"azext.minCliCoreVersion": "2.3.1"
}
12 changes: 12 additions & 0 deletions src/datashare/azext_datashare/generated/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

__path__ = __import__('pkgutil').extend_path(__path__, __name__)
54 changes: 54 additions & 0 deletions src/datashare/azext_datashare/generated/_client_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------


def cf_datashare(cli_ctx, *_):
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from ..vendored_sdks.datashare import DataShareManagementClient
return get_mgmt_service_client(cli_ctx, DataShareManagementClient)


def cf_account(cli_ctx, *_):
return cf_datashare(cli_ctx).account


def cf_consumer_invitation(cli_ctx, *_):
return cf_datashare(cli_ctx).consumer_invitation


def cf_data_set(cli_ctx, *_):
return cf_datashare(cli_ctx).data_set


def cf_data_set_mapping(cli_ctx, *_):
return cf_datashare(cli_ctx).data_set_mapping


def cf_invitation(cli_ctx, *_):
return cf_datashare(cli_ctx).invitation


def cf_share(cli_ctx, *_):
return cf_datashare(cli_ctx).share


def cf_provider_share_subscription(cli_ctx, *_):
return cf_datashare(cli_ctx).provider_share_subscription


def cf_share_subscription(cli_ctx, *_):
return cf_datashare(cli_ctx).share_subscription


def cf_consumer_source_data_set(cli_ctx, *_):
return cf_datashare(cli_ctx).consumer_source_data_set


def cf_synchronization_setting(cli_ctx, *_):
return cf_datashare(cli_ctx).synchronization_setting


def cf_trigger(cli_ctx, *_):
return cf_datashare(cli_ctx).trigger
Loading