# iotpcs

> Command Line Interface for deploying pre-configured IoT solutions through Azure

Latest version **1.0.0** (published 2017-09-25) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install iotpcs
pnpm add iotpcs
yarn add iotpcs
bun add iotpcs
```

Provides the command `pcs`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2017-09-25 |
| First published | 2017-09-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 13 |
| Known vulnerabilities | 0 (+28 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 33 |
| Author | Parvez Pathan |
| Maintainers | ppathan |
| Keywords | remotemonitoring, pcs, cli |

## Links

- npm: https://www.npmjs.com/package/iotpcs
- Repository: https://github.com/Azure/azure-remote-monitoring-cli
- Homepage: https://github.com/Azure/azure-remote-monitoring-cli#readme
- Issues: https://github.com/Azure/azure-remote-monitoring-cli/issues
- npm.io page: https://npm.io/package/iotpcs

## Dependencies (13)

- [btoa](https://npm.io/package/btoa.md) ^1.1.2
- [ssh2](https://npm.io/package/ssh2.md) ^0.5.5
- [azure](https://npm.io/package/azure.md) ^2.0.0-preview
- [js-yaml](https://npm.io/package/js-yaml.md) ^3.10.0
- [ms-rest](https://npm.io/package/ms-rest.md) ^2.2.0
- [inquirer](https://npm.io/package/inquirer.md) ^3.1.0
- [commander](https://npm.io/package/commander.md) ^2.9.0
- [node-forge](https://npm.io/package/node-forge.md) ^0.7.1
- [azure-graph](https://npm.io/package/azure-graph.md) ^2.2.0
- [json-loader](https://npm.io/package/json-loader.md) ^0.5.4
- [ms-rest-azure](https://npm.io/package/ms-rest-azure.md) ^2.1.2
- [azure-arm-resource](https://npm.io/package/azure-arm-resource.md) ^2.0.0-preview
- [@kubernetes/typescript-node](https://npm.io/package/@kubernetes/typescript-node.md) ^0.1.1

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2017-09-25

## README

[![Build][build-badge]][build-url]
[![Issues][issues-badge]][issues-url]
[![Gitter][gitter-badge]][gitter-url]

Azure IoT PCS CLI Overview
==========================

Command Line Interface for deploying an IoT pre-configured solution into a
user's subscription.

This CLI has the ability to deploy two configurations of PCS solutions:

1. Basic - deploys all resources to a single VM.
2. Enterprise - deploys resources using Azure Container Service and Kubernetes across multiple VMs.

Dependencies
============
The command line interface depends on:

* [nodejs](https://nodejs.org/en/) used as the runtime for the CLI.  Please install node before attempting a deployment.

## Basic

The purpose of the basic deployment is to demo the capabilities of the system
and requires minimal setup, deploying all resources to a single VM.

Basic deployment provisions following resources:

1. [Azure IoT Hub](https://azure.microsoft.com/en-us/services/iot-hub/)
2. [Azure Cosmos DB](https://docs.microsoft.com/en-us/azure/cosmos-db/create-documentdb-dotnet)
3. [Azure Storage](https://azure.microsoft.com/en-us/services/storage/)
4. [Single instance of Azure Virtual Machine with Docker Extension](https://azure.microsoft.com/en-us/services/virtual-machines/)

At the end of deployment, Remote Monitoring WebApp and all the microservices
are ready for demo pursposes.

## Enterprise

The Enterprise deployment offers a production ready deployment that can be
scaled up or down as needed. It uses
[Azure Container Service](https://azure.microsoft.com/en-us/services/container-service/)
and [Kubernetes](https://kubernetes.io/) for orchestration. It also requires
some manual steps in running commands through different CLIs like
[az](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli) and
[kubectl](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)
in addition to ```pcs```.

Enterprise deployment provisions following resources:

1. [Azure IoT Hub](https://azure.microsoft.com/en-us/services/iot-hub/)
2. [Azure Cosmos DB](https://docs.microsoft.com/en-us/azure/cosmos-db/create-documentdb-dotnet)
3. [Azure Container Service](https://azure.microsoft.com/en-us/services/container-service/)
   which also provisions following:
   1. [Azure Storage](https://azure.microsoft.com/en-us/services/storage/)
   2. [Three instances of Azure Virtual Machine with Docker](https://azure.microsoft.com/en-us/services/virtual-machines/)

How to use the CLI
==================

## CLI setup

1. Clone the project
1. From a command prompt run: 
    - `npm install` 
    - `npm start`
    - `npm link`

## Basic Deployment

### Deploy Azure Resources

1. If you haven't logged in with your Azure account from the command prompt run `pcs login`.
1. Run either `pcs` or `pcs -t remotemonitoring -s basic`.  These are equivalent in that they will both deploy a basic deployment (i.e. a deployment to a single VM).
1. Follow the on-screen prompts
1. The results of the deployment will be saved to a file named `output.json`

### Verify the Web UI and Microservices are deployed

Click on the link that is shown in the output window, it will take you to
the Remote Monitoring WebApp

## Enterprise Deployment

### Dependendencies

- [Install Azure CLI 2.0](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)
- [Install kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)

> **Important** \
\
Make sure the path of az and kubectl are set in environment variables.
You should be able to type 'az' or 'kubectl' in console window and see
the help content.

### Deploy Azure Resources

1. `pcs -t remotemonitoring -s enterprise`
2. Follow the on-screen prompts
3. The results of the deployment will be saved to a file named {deployment-name}-output.json 

**Sample output format:**
```json
"resourceGroup" : {
    "type": "string",
    "value": "{myResourceGroupName}"
},
"iotHubHostName": {
    "type": "string",
    "value": "{myIoTHubHostName}"
},
"iotHubConnectionString": {
    "type": "string",
    "value": "{HostName={hubname}.azure-devices.net;
    SharedAccessKeyName={policy type};SharedAccessKey={Access Key};}"
},
"documentDBConnectionString" : {
    "type": "string",
    "value": "{AccountEndpoint={URI};AccountKey={Key};}"
}
```

> **Important** \
\
To create a service principal, you must have permissions to register an \
application with your Azure Active Directory(AAD) tenant, and to assign \
the application to a role in your subscription. To see if you have the \
required permissions, [check in the Portal](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal#required-permissions).

### Create a Container Service for Kubernetes

1. `az login`
2. `az account set --subscription {subscriptionId }` from step 3 of
   [Deploy Azure Resources](README.md#deploy-azure-resources-1)
3. `az acs create -n {myClusterName} -d {myDNSPrefix} -g {resouceGroup} -t kubernetes --generate-ssh-keys`
   where resouceGroup from step 3 of
   [Deploy Azure Resources](README.md#deploy-azure-resources-1)
4. `az acs kubernetes get-credentials -g {myResorceGroupName} -n {myClusterName} --ssh-key-file {path to ssh key file to use}`

### Deploy Docker images through Kubernetes

To verify access test with `kubectl get nodes`

1. `kubectl create -f .\remotemonitoring\scripts\nginx-ingress-controller.yaml`
2. Go to your resource group on [portal.azure.com](http://portal.azure.com)
   and set up friendly DNS name for Public IP address that got created in
   step 3 of
   [Create a Container Service for Kubernetes](README.md#create-a-container-service-for-kubernetes).
   It will start with **{myClusterName}**. To confirm match the IP address
   with "LoadBalancer Ingress" by running `kubectl describe svc nginx-ingress`
3. Add actual values in the ConfigMap section in file
   [all-in-one.yaml](https://github.com/Azure/pcs-cli/blob/master/remotemonitoring/scripts/all-in-one.yaml)
   and
   [deployment-configmap.yaml](https://github.com/Azure/pcs-cli/blob/master/remotemonitoring/scripts/individual/deployment-configmap.yaml).
   Values to replace will be of format **"{...}"**. Some examples below.
    * **{DNS}** with value from step 2
    * **{IoT Hub connection string}**
    * **{DocumentDB connection string}**
4. `kubectl create -f .\remotemonitoring\scripts\all-in-one.yaml`

> **Important** \
\
If your account doesn't have the Azure Active Directory (AAD) and subscription
permissions to create a service principal, then the command generates an error
similar to **Insufficient privileges to complete the operation**. \
Also, when using **--generate-ssh-keys**, if one key already exists at
`~/.ssh/id_rsa` then it will be used.

### Verify the Web UI and Microservices are deployed

1. Click on the link that is shown in the output window, it will take you to
   the Remote Monitoring WebApp
2. Go to {DNS}/hubmanager/v1/status to see HubManager microservice status
3. Go to {DNS}/devices/v1/status to see Devices microservice status

Configuration
=============

## Kubernetes Dashboard

To view Kubernetes dashboard, run the following command, which will start a local
web proxy for your cluster (it will start a local server at http://127.0.0.1:8001/ui):

`az acs kubernetes browse -g {myResourceGroupName} -n {myClusterName} --ssh-key-file {path to ssh file}`

## CLI Options

To get help run `pcs -h` or `--help` \
To get the version run `pcs -v` or `--version`

Feedback
========

Please enter issues, bugs, or suggestions as GitHub Issues here: https://github.com/Azure/pcs-cli/issues.

Related
=======

* [Contributing and Development setup](CONTRIBUTING.md)


[build-badge]: https://img.shields.io/travis/Azure/iot-pcs-cli.svg
[build-url]: https://travis-ci.com/Azure/iot-pcs-cli
[issues-badge]: https://img.shields.io/github/issues/azure/iot-pcs-cli.svg
[issues-url]: https://github.com/azure/iot-pcs-cli/issues
[gitter-badge]: https://img.shields.io/gitter/room/azure/iot-pcs.js.svg
[gitter-url]: https://gitter.im/azure/iot-pcs

---
_Source: https://npm.io/package/iotpcs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
