Skip to content

Commit

Permalink
[Breadth Coverage] Time Series Insights (#1539)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiasli authored Apr 29, 2020
1 parent e6c21fd commit 6827793
Show file tree
Hide file tree
Showing 37 changed files with 13,034 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@

/src/hpc-cache/ @qianwens

/src/timeseriesinsights/ @jiasli

/src/portal/ @YalinLi0312

/src/import-export/ @arrownj
Expand Down
8 changes: 8 additions & 0 deletions src/timeseriesinsights/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. :changelog:
Release History
===============

0.1.0
++++++
* Initial release.
75 changes: 75 additions & 0 deletions src/timeseriesinsights/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
Microsoft Azure CLI 'timeseriesinsights' Extension
==========================================

This package is for the 'timeseriesinsights' extension:

```sh
az timeseriesinsights
```

### Create a resource group for the environments

```sh
rg={resource_group_name}
az group create -n $rg
```

### Create a standard environment

```sh
env={standard_environment_name}
az timeseriesinsights environment standard create -g $rg --name $env --location westus --sku-name S1 --sku-capacity 1 --data-retention-time P31D --partition-key DeviceId1 --storage-limit-exceeded-behavior PauseIngress
```

### Create a storage account and use it to create a long-term environment

```sh
storage={storage_account_name}
env_lt={longterm_environment_name}

az storage account create -g $rg -n $storage --https-only
key=$(az storage account keys list -g $rg -n $storage --query [0].value --output tsv)

az timeseriesinsights environment longterm create -g $rg --name $env_lt --location westus --sku-name L1 --sku-capacity 1 --data-retention 7 --time-series-id-properties DeviceId1 --storage-account-name $storage --storage-management-key $key
```

### Create an event hub and use it to create an event source

```sh
ehns={eventhub_namespace}
eh={eventhub_name}

az eventhubs namespace create -g $rg -n $ehns
es_resource_id=$(az eventhubs eventhub create -g $rg -n $eh --namespace-name $ehns --query id --output tsv)
shared_access_key=$(az eventhubs namespace authorization-rule keys list -g $rg --namespace-name $ehns -n RootManageSharedAccessKey --query primaryKey --output tsv)

az timeseriesinsights event-source eventhub create -g $rg --environment-name $env --name {es1} --key-name RootManageSharedAccessKey --shared-access-key $shared_access_key --event-source-resource-id $es_resource_id --consumer-group-name '$Default' --timestamp-property-name DeviceId
```

### Create an IoT hub and use it to create an event source

```sh
iothub={iothub_name}
es_resource_id=$(az iot hub create -g $rg -n $iothub --query id --output tsv)
shared_access_key=$(az iot hub policy list -g $rg --hub-name $iothub --query "[?keyName=='iothubowner'].primaryKey" --output tsv)
az timeseriesinsights event-source iothub create -g $rg --environment-name $env --name {es2} --consumer-group-name '$Default' --key-name iothubowner --shared-access-key $shared_access_key --event-source-resource-id $es_resource_id --timestamp-property-name DeviceId
```

### Create a reference data set

```sh
az timeseriesinsights reference-data-set create -g $rg --environment-name $env --name {rds} --key-properties DeviceId1 String DeviceFloor Double --data-string-comparison-behavior Ordinal
```

### Create an access policy

```sh
az timeseriesinsights access-policy create -g $rg --environment-name $env --name ap1 --principal-object-id 001 --description "some description" --roles Contributor Reader
```

### Delete the environment and all its sub-resources

```sh
az timeseriesinsights environment delete --resource-group $rg --name $env
az group delete -n $rg
```
32 changes: 32 additions & 0 deletions src/timeseriesinsights/azext_timeseriesinsights/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from azure.cli.core import AzCommandsLoader

from azext_timeseriesinsights._help import helps # pylint: disable=unused-import


class TimeSeriesInsightsClientCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azext_timeseriesinsights._client_factory import cf_timeseriesinsights
timeseriesinsights_custom = CliCommandType(
operations_tmpl='azext_timeseriesinsights.custom#{}',
client_factory=cf_timeseriesinsights)
super(TimeSeriesInsightsClientCommandsLoader, self).__init__(cli_ctx=cli_ctx,
custom_command_type=timeseriesinsights_custom)

def load_command_table(self, args):
from azext_timeseriesinsights.commands import load_command_table
load_command_table(self, args)
return self.command_table

def load_arguments(self, command):
from azext_timeseriesinsights._params import load_arguments
load_arguments(self, command)


COMMAND_LOADER_CLS = TimeSeriesInsightsClientCommandsLoader
26 changes: 26 additions & 0 deletions src/timeseriesinsights/azext_timeseriesinsights/_client_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------


def cf_timeseriesinsights(cli_ctx, *_):
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from .vendored_sdks.timeseriesinsights import TimeSeriesInsightsClient
return get_mgmt_service_client(cli_ctx, TimeSeriesInsightsClient)


def cf_environments(cli_ctx, *_):
return cf_timeseriesinsights(cli_ctx).environments


def cf_event_sources(cli_ctx, *_):
return cf_timeseriesinsights(cli_ctx).event_sources


def cf_reference_data_sets(cli_ctx, *_):
return cf_timeseriesinsights(cli_ctx).reference_data_sets


def cf_access_policies(cli_ctx, *_):
return cf_timeseriesinsights(cli_ctx).access_policies
Loading

0 comments on commit 6827793

Please sign in to comment.