├── .gitattributes
├── .gitignore
├── .gitmodules
├── LICENSE
├── README.md
├── docs
├── CODEOWNERS
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── DEVELOPMENT.md
├── ISSUE_TEMPLATE.md
└── PULL_REQUEST_TEMPLATE.md
└── scripts
├── build
├── build.cmd
├── docker
├── README.md
├── docker-compose.yml
└── run
├── git
├── .functions.sh
├── pre-commit-runner.sh
├── pre-commit.sh
├── release.sh
├── setup
└── setup.cmd
├── iothub
├── .functions.sh
├── create-hub.sh
├── list-hubs.sh
├── list-subscriptions.sh
├── select-subscription.sh
└── show-hub.sh
├── local
├── .env
├── config
│ └── nginx.conf
└── docker-compose.yml
└── update-gitsubmodules.sh
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Set bash scripts to always be in LF
2 | * text=auto eol=lf
3 | *.sh text eol=lf
4 | scripts/build text eol=lf
5 | scripts/docker/run text eol=lf
6 | scripts/git/setup text eol=lf
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ### Custom
2 |
3 | _dev/
4 | *.crt
5 | *._gistcs
6 | *.tgz
7 | *.tar
8 | *.exe
9 | *.bck
10 |
11 |
12 |
13 | ### Java
14 |
15 | # Compiled class file
16 | *.class
17 |
18 | # Log file
19 | *.log
20 |
21 | # BlueJ files
22 | *.ctxt
23 |
24 | # Mobile Tools for Java (J2ME)
25 | .mtj.tmp/
26 |
27 | # Package Files #
28 | *.jar
29 | *.war
30 | *.ear
31 | *.zip
32 | *.tar.gz
33 | *.rar
34 |
35 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
36 | hs_err_pid*
37 |
38 |
39 | ### Gradle
40 |
41 | **/.gradle
42 | /build/
43 |
44 | # Ignore Gradle GUI config
45 | gradle-app.setting
46 |
47 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
48 | !gradle-wrapper.jar
49 |
50 | # Cache of project
51 | .gradletasknamecache
52 |
53 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
54 | # gradle/wrapper/gradle-wrapper.properties
55 |
56 |
57 |
58 |
59 | ### MacOS
60 |
61 | *.DS_Store
62 | .AppleDouble
63 | .LSOverride
64 |
65 | # Icon must end with two \r
66 | Icon
67 |
68 |
69 | # Thumbnails
70 | ._*
71 |
72 | # Files that might appear in the root of a volume
73 | .DocumentRevisions-V100
74 | .fseventsd
75 | .Spotlight-V100
76 | .TemporaryItems
77 | .Trashes
78 | .VolumeIcon.icns
79 | .com.apple.timemachine.donotpresent
80 |
81 | # Directories potentially created on remote AFP share
82 | .AppleDB
83 | .AppleDesktop
84 | Network Trash Folder
85 | Temporary Items
86 | .apdisk
87 |
88 | ### Vagrant
89 |
90 | .vagrant/
91 |
92 | ### SublimeText
93 |
94 | # cache files for sublime text
95 | *.tmlanguage.cache
96 | *.tmPreferences.cache
97 | *.stTheme.cache
98 |
99 | # workspace files are user-specific
100 | *.sublime-workspace
101 |
102 | # project files should be checked into the repository, unless a significant
103 | # proportion of contributors will probably not be using SublimeText
104 | # *.sublime-project
105 |
106 | # sftp configuration file
107 | sftp-config.json
108 |
109 | # Package control specific files
110 | Package Control.last-run
111 | Package Control.ca-list
112 | Package Control.ca-bundle
113 | Package Control.system-ca-bundle
114 | Package Control.cache/
115 | Package Control.ca-certs/
116 | Package Control.merged-ca-bundle
117 | Package Control.user-ca-bundle
118 | oscrypto-ca-bundle.crt
119 | bh_unicode_properties.cache
120 |
121 | # Sublime-github package stores a github token in this file
122 | # https://packagecontrol.io/packages/sublime-github
123 | GitHub.sublime-settings
124 |
125 |
126 | ### SBT
127 |
128 | dist/*
129 | target/
130 | lib_managed/
131 | src_managed/
132 | project/boot/
133 | project/plugins/project/
134 | .history
135 | .cache
136 | .lib/
137 |
138 |
139 | ### NetBeans
140 |
141 | nbproject/private/
142 | build/
143 | nbbuild/
144 | dist/
145 | nbdist/
146 | .nb-gradle/
147 |
148 |
149 | ### JetBrains
150 |
151 | # User-specific stuff:
152 | .idea/**/workspace.xml
153 | .idea/**/tasks.xml
154 | .idea/dictionaries
155 |
156 | # Sensitive or high-churn files:
157 | .idea/**/dataSources/
158 | .idea/**/dataSources.ids
159 | .idea/**/dataSources.xml
160 | .idea/**/dataSources.local.xml
161 | .idea/**/sqlDataSources.xml
162 | .idea/**/dynamic.xml
163 | .idea/**/uiDesigner.xml
164 |
165 | # Gradle:
166 | .idea/**/gradle.xml
167 | .idea/**/libraries
168 |
169 | # Mongo Explorer plugin:
170 | .idea/**/mongoSettings.xml
171 |
172 | ## File-based project format:
173 | *.iws
174 |
175 | ## Plugin-specific files:
176 |
177 | # IntelliJ
178 | /out/
179 |
180 | # mpeltonen/sbt-idea plugin
181 | .idea_modules/
182 |
183 | # JIRA plugin
184 | atlassian-ide-plugin.xml
185 |
186 | # Cursive Clojure plugin
187 | .idea/replstate.xml
188 |
189 | # Crashlytics plugin (for Android Studio and IntelliJ)
190 | com_crashlytics_export_strings.xml
191 | crashlytics.properties
192 | crashlytics-build.properties
193 | fabric.properties
194 |
195 |
196 | ### Ensime
197 |
198 | .ensime
199 | .ensime_cache/
200 | .ensime_lucene/
201 |
202 |
203 | # Eclipse
204 |
205 | .metadata
206 | bin/
207 | tmp/
208 | *.tmp
209 | *.bak
210 | *.swp
211 | *~.nib
212 | local.properties
213 | .settings/
214 | .loadpath
215 | .recommenders
216 |
217 | # External tool builders
218 | .externalToolBuilders/
219 |
220 | # Locally stored "Eclipse launch configurations"
221 | *.launch
222 |
223 | # PyDev specific (Python IDE for Eclipse)
224 | *.pydevproject
225 |
226 | # CDT-specific (C/C++ Development Tooling)
227 | .cproject
228 |
229 | # Java annotation processor (APT)
230 | .factorypath
231 |
232 | # PDT-specific (PHP Development Tools)
233 | .buildpath
234 |
235 | # sbteclipse plugin
236 | .target
237 |
238 | # Tern plugin
239 | .tern-project
240 |
241 | # TeXlipse plugin
242 | .texlipse
243 |
244 | # STS (Spring Tool Suite)
245 | .springBeans
246 |
247 | # Code Recommenders
248 | .recommenders/
249 |
250 | # Scala IDE specific (Scala & Java development for Eclipse)
251 | .cache-main
252 | .scala_dependencies
253 | .worksheet
254 |
255 | # JetBrains Rider
256 | .idea/
257 | *.sln.iml
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 | # Overrides
269 |
270 | gradle/
271 |
272 | # White list
273 |
274 | !gradle-wrapper.jar
275 | !java/gradle
276 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "device-simulation"]
2 | path = device-simulation
3 | url = https://github.com/Azure/device-simulation-dotnet.git
4 | [submodule "webui"]
5 | path = webui
6 | url = https://github.com/Azure/azure-iot-pcs-remote-monitoring-webui.git
7 | [submodule "cli"]
8 | path = cli
9 | url = https://github.com/Azure/pcs-cli
10 | [submodule "services"]
11 | path = services
12 | url = https://github.com/Azure/remote-monitoring-services-java
13 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) Microsoft Corporation. All rights reserved.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [![Build status][build-badge]][build-url]
2 | [![Issues][issues-badge]][issues-url]
3 | [![Gitter][gitter-badge]][gitter-url]
4 |
5 | ### **Note:** As of December 10th 2020, Remote Monitoring solution accelerator is no longer supported. All supporting repositories have been archived. Check the [FAQ](https://docs.microsoft.com/en-us/azure/iot-accelerators/iot-accelerators-faq) to learn more.
6 |
7 | Remote Monitoring Solution with Azure IoT
8 | ========
9 |
10 |

11 |
12 |
13 | Overview
14 | ========
15 | > There is a .NET version of this repo available [here](https://github.com/Azure/azure-iot-pcs-remote-monitoring-dotnet)
16 |
17 | Remote monitoring helps you get better visibility into your devices, assets, and
18 | sensors wherever they happen to be located. You can collect and analyze real-time
19 | device data using a remote monitoring solution that triggers automatic alerts and
20 | actions — from remote diagnostics to maintenance requests. You can also command and
21 | control your devices.
22 |
23 | [Azure IoT Hub][iot-hub]
24 | is a key building block of the remote monitoring solution. IoT Hub is a fully
25 | managed service that enables reliable and secure bidirectional communications between
26 | millions of IoT devices and a solution back end.
27 |
28 | Check out the [Interactive Demo](http://www.microsoftazureiotsuite.com/demos/remotemonitoring)
29 | for a detailed overview of features and use cases.
30 |
31 | To get started you can follow along with the [Getting Started](#getting-started)
32 | for a command line deployment. You can also deploy using the web interface
33 | at https://www.azureiotsolutions.com.
34 |
35 | ### Documentation
36 | See more documentation [here](https://docs.microsoft.com/azure/iot-suite/).
37 |
38 | Getting Started
39 | ===============
40 |
41 | ## Deploy a solution
42 | There are three ways to deploy a solution:
43 | 1) Deploy using the web interface using the instructions [here](https://docs.microsoft.com/azure/iot-suite/iot-suite-remote-monitoring-deploy).
44 | 2) Deploy using the [command line](https://docs.microsoft.com/azure/iot-suite/iot-suite-remote-monitoring-deploy-cli).
45 | 3) Deploy locally using [Visual Studio](https://docs.microsoft.com/en-us/azure/iot-accelerators/iot-accelerators-remote-monitoring-deploy-local) or [Docker](https://docs.microsoft.com/en-us/azure/iot-accelerators/iot-accelerators-remote-monitoring-deploy-local-docker).
46 |
47 | ## Create additional simulated devices
48 | Once you have a solution up and running, you can [create additional simluated devices](https://docs.microsoft.com/azure/iot-suite/iot-suite-remote-monitoring-test). You can then stop the default simulated devices by calling the simulation endpoint with the instructions [here](https://github.com/Azure/device-simulation-dotnet/wiki/%5BAPI-Specifications%5D-Simulations#stop-simulation).
49 |
50 | ## Connect a physical device!
51 | By default, the solution once spun up uses simulated devices. You can start adding your
52 | own devices with the instructions [here](https://docs.microsoft.com/azure/iot-suite/iot-suite-connecting-devices-node).
53 |
54 | ## Customize the Web UI
55 | You can find information about customizing the remote monitoring solution [here](https://docs.microsoft.com/azure/iot-suite/iot-suite-remote-monitoring-customize).
56 |
57 | Architecture Overview
58 | =====================
59 |
60 |

61 |
62 |
63 | [Learn more](https://docs.microsoft.com/azure/iot-suite/iot-suite-remote-monitoring-sample-walkthrough) about the Remote Monitoring architecture, including the use of microservices and Docker containers.
64 |
65 | ## Components
66 | * [Remote Monitoring Web UI](https://github.com/Azure/pcs-remote-monitoring-webui)
67 | * [Command Line Interface (CLI)](https://github.com/Azure/pcs-cli)
68 | * [Micro Services](https://github.com/Azure/remote-monitoring-services-java)
69 | * [Application Gateway (SSL Proxy WebApp)](https://github.com/Azure/reverse-proxy-dotnet)
70 | * [API Gateway](https://github.com/Azure/azure-iot-pcs-remote-monitoring-dotnet/tree/master/reverse-proxy)
71 |
72 | How-to and Troubleshooting Resources
73 | ====================================
74 | * [Developer Troubleshooting Guide](https://github.com/Azure/azure-iot-pcs-remote-monitoring-java/wiki/Developer-Troubleshooting-Guide)
75 | * [Developer Reference Guide](https://github.com/Azure/azure-iot-pcs-remote-monitoring-java/wiki/Developer-Reference-Guide#running-all-pcs-microservices-locally)
76 |
77 | Feedback
78 | ========
79 | * If you have feedback, feature requests, or find a problem, you can create
80 | a new issue in the [GitHub Issues][issues-url]
81 | * We have a [User Voice](https://feedback.azure.com/forums/321918-azure-iot)
82 | channel to receive suggestions for features and future supported scenarios.
83 |
84 | Contributing
85 | ============
86 | Refer to our [contribution guidelines](CONTRIBUTING.md). We love PRs!
87 |
88 | License
89 | =======
90 | Copyright (c) Microsoft Corporation. All rights reserved.
91 | Licensed under the [MIT](LICENSE) License.
92 |
93 | [build-badge]: https://solutionaccelerators.visualstudio.com/RemoteMonitoring/_apis/build/status/Consolidated%20Repo
94 | [build-url]: https://solutionaccelerators.visualstudio.com/RemoteMonitoring/_build/latest?definitionId=25
95 | [issues-badge]: https://img.shields.io/github/issues/azure/azure-iot-pcs-remote-monitoring-java.svg
96 | [issues-url]: https://github.com/azure/azure-iot-pcs-remote-monitoring-java/issues
97 | [gitter-badge]: https://img.shields.io/gitter/room/azure/iot-solutions.js.svg
98 | [gitter-url]: https://gitter.im/Azure/iot-solutions
99 | [azure-active-directory]: https://azure.microsoft.com/services/active-directory
100 | [iot-hub]: https://azure.microsoft.com/services/iot-hub
101 | [cosmos-db]: https://azure.microsoft.com/services/cosmos-db
102 | [container-service]: https://azure.microsoft.com/services/container-service
103 | [storage-account]: https://docs.microsoft.com/azure/storage/common/storage-introduction#types-of-storage-accounts
104 | [virtual-machines]: https://azure.microsoft.com/services/virtual-machines
105 | [web-application]: https://azure.microsoft.com/services/app-service/web
106 |
--------------------------------------------------------------------------------
/docs/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # For more info see https://help.github.com/articles/about-codeowners
2 |
3 | # Order is important; the last matching pattern takes the most precedence.
4 |
5 | * @ppathan @ankitscribbles @isaac-dasan
6 |
7 | LICENSE @ankitscribbles @isaac-dasan @ppathan
8 |
--------------------------------------------------------------------------------
/docs/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | Microsoft Open Source Code of Conduct
2 | =====================================
3 |
4 | This project has adopted the
5 | [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct).
6 |
7 | For more information see the
8 | [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq)
9 | or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with
10 | any additional questions or comments.
11 |
--------------------------------------------------------------------------------
/docs/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | We'll be glad to accept patches and contributions to the project. There are
2 | just few guidelines we ask to follow.
3 |
4 | Contribution License Agreement
5 | ==============================
6 |
7 | If you want/plan to contribute, we ask you to sign a
8 | [CLA](https://cla.microsoft.com/) (Contribution License Agreement).
9 | A friendly bot will remind you about it when you submit a pull-request.
10 |
11 | Submitting a contribution
12 | =========================
13 |
14 | It's generally best to start by
15 | [opening a new issue](https://help.github.com/articles/creating-an-issue)
16 | describing the work you intend to submit. Even for minor tasks, it's helpful
17 | to know what contributors are working on. Please mention in the initial issue
18 | that you are planning to work on it, so that it can be assigned to you.
19 |
20 | Follow the usual GitHub flow process of
21 | [forking the project](https://help.github.com/articles/fork-a-repo),
22 | and setup a new branch to work in. Each group of changes should be done in
23 | separate branches, in order to ensure that a pull request only
24 | includes the changes related to one issue.
25 |
26 | Any significant change should almost always be accompanied by tests. Look at
27 | the existing tests to see the testing approach and style used.
28 |
29 | Follow the project coding style, to ensure consistency and quick code reviews.
30 | For more information about the development workflow, have a look at
31 | [the development notes](DEVELOPMENT.md).
32 |
33 | Do your best to have clear commit messages for each change, in order to keep
34 | consistency throughout the project. Reference the issue number (#num). A good
35 | commit message serves at least these purposes:
36 | * Speed up the pull request review process
37 | * Help future developers to understand the purpose of your code
38 | * Help the maintainer write release notes
39 |
40 | One-line messages are fine for small changes, but bigger changes should look
41 | like this:
42 | ```
43 | $ git commit -m "A brief summary of the commit
44 | >
45 | > A paragraph describing what changed and its impact."
46 | ```
47 |
48 | Finally, push the commits to your fork, submit a pull request, wait for the
49 | automated feedback from Travis CI, and follow the code review progress. The
50 | team might ask for some
51 | [changes](https://help.github.com/articles/committing-changes-to-a-pull-request-branch-created-from-a-fork)
52 | before merging the pull request.
53 |
--------------------------------------------------------------------------------
/docs/DEVELOPMENT.md:
--------------------------------------------------------------------------------
1 | Azure IoT Hub setup
2 | ===================
3 |
4 | To work on Remote Monitoring you will need to setup some dependencies
5 | first:
6 |
7 | * Azure IoT Hub
8 | * CosmosDb SQL (DocumentDb)
9 |
10 | Azure IoT Hub setup
11 | ===================
12 |
13 | The project includes some Bash scripts to help you with this setup:
14 |
15 | * Create new IoT Hub: `./scripts/iothub/create-hub.sh`
16 | * List existing hubs: `./scripts/iothub/list-hubs.sh`
17 | * Show IoT Hub details (e.g. keys): `./scripts/iothub/show-hub.sh`
18 |
19 | and in case you had multiple Azure subscriptions:
20 |
21 | * Show subscriptions list: `./scripts/iothub/list-subscriptions.sh`
22 | * Change current subscription: `./scripts/iothub/select-subscription.sh`
23 |
24 | CosmosDb SQL (DocumentDb)
25 | =========================
26 |
27 | To setup CosmosDb you will need to use the Azure Portal.
--------------------------------------------------------------------------------
/docs/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | # Type of issue
2 | - [ ] Bug
3 | - [ ] New feature
4 | - [ ] Improvement
5 |
6 | # Description
7 | ...
8 |
9 | # Screenshot
10 |
11 | # Steps to reproduce
12 | 1. [First step]
13 | 2. [Second step]
14 | 3. [and so on...]
15 |
16 | # Expected behavior
17 | ...
18 |
19 | # Current behavior
20 | ...
21 |
22 | # Known workarounds
23 | ...
24 |
25 | # Possible solution
26 | ...
27 |
28 |
29 | # Context and Environment
30 | * Operating System: ...
31 | * GitHub branch: ...
32 | * .NET Runtime: ...
33 |
--------------------------------------------------------------------------------
/docs/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | # Types of changes
2 |
3 | - [ ] Bug fix (non-breaking change which fixes an issue)
4 | - [ ] New feature (non-breaking change which adds functionality)
5 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
6 |
7 | # Checklist:
8 |
9 | - [ ] All new and existing tests passed.
10 | - [ ] The code follows the code style and conventions of this project.
11 | - [ ] The change requires a change to the documentation.
12 | - [ ] I have updated the documentation accordingly.
13 |
14 | # Description of the change
15 |
16 | ...
17 |
18 | # Motivation for the change
19 |
20 | ...
21 |
--------------------------------------------------------------------------------
/scripts/build:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | APP_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )/"
4 |
5 | cd $APP_HOME
6 |
--------------------------------------------------------------------------------
/scripts/build.cmd:
--------------------------------------------------------------------------------
1 | @ECHO off
2 | setlocal
3 |
4 | :: strlen("\scripts\") => 9
5 | SET APP_HOME=%~dp0
6 | SET APP_HOME=%APP_HOME:~0,-9%
7 | cd %APP_HOME%
8 |
9 | IF NOT ERRORLEVEL 0 GOTO FAIL
10 |
11 | :: - - - - - - - - - - - - - -
12 | goto :END
13 |
14 | :FAIL
15 | echo Command failed
16 | endlocal
17 | exit /B 1
18 |
19 | :END
20 | endlocal
21 |
--------------------------------------------------------------------------------
/scripts/docker/README.md:
--------------------------------------------------------------------------------
1 | How to launch the solution using Docker Compose
2 | ===============================================
3 |
4 | 1. Install Docker and Docker Compose
5 | 1. https://docs.docker.com/engine/installation
6 | 2. https://docs.docker.com/compose/install
7 | 2. Set all the environment variables in the
8 | docker-compose.yml file, directly in the file
9 | or in your system.
10 | 3. Open a console and go into the folder containing
11 | the [docker-compose.yml](docker-compose.yml) file.
12 | 4. Run `docker-compose up`
13 | 5. Open the browser at http://127.0.0.1:10080
14 |
--------------------------------------------------------------------------------
/scripts/docker/docker-compose.yml:
--------------------------------------------------------------------------------
1 | # Usage:
2 | # - install Docker Compose, see https://docs.docker.com/compose/install
3 | # - open a console and `cd` into the folder that contains this file
4 | # - note how the file references many environment variables, either set
5 | # them in your system or edit this file adding the values here
6 | # - run `docker-compose up`
7 | # - open the browser at http://127.0.0.1:10443
8 | #
9 | # For more information see
10 | # https://github.com/Azure/azure-iot-pcs-remote-monitoring-java
11 |
12 | version: "3"
13 |
14 | services:
15 | reverseproxy:
16 | image: azureiotpcs/remote-monitoring-nginx:latest
17 | ports:
18 | - "10443:443"
19 | depends_on:
20 | - webui
21 | - auth
22 | - iothubmanager
23 | - devicesimulation
24 | - telemetry
25 | - config
26 | volumes:
27 | - /app/certs:/app/certs:ro
28 |
29 | webui:
30 | image: azureiotpcs/pcs-remote-monitoring-webui:latest
31 | ports:
32 | - "443:443"
33 | depends_on:
34 | - auth
35 | - iothubmanager
36 | - devicesimulation
37 | - telemetry
38 | - config
39 | volumes:
40 | - /app/webui-config.js:/app/build/config.js:ro
41 |
42 | auth:
43 | # TODO Use Java container
44 | image: azureiotpcs/pcs-auth-dotnet
45 | ports:
46 | - "9001:9001"
47 | environment:
48 | - PCS_AUTH_ISSUER
49 | - PCS_AUTH_AUDIENCE
50 | - PCS_APPLICATION_SECRET
51 |
52 | iothubmanager:
53 | image: azureiotpcs/iothub-manager-java
54 | depends_on:
55 | - storageadapter
56 | ports:
57 | - "9002:9002"
58 | environment:
59 | - PCS_IOTHUB_CONNSTRING
60 | - PCS_AUTH_ISSUER
61 | - PCS_AUTH_AUDIENCE
62 | - PCS_APPLICATION_SECRET
63 | - PCS_STORAGEADAPTER_WEBSERVICE_URL=http://storageadapter:9022/v1
64 |
65 | devicesimulation:
66 | image: azureiotpcs/device-simulation-dotnet:latest
67 | depends_on:
68 | - storageadapter
69 | ports:
70 | - "9003:9003"
71 | environment:
72 | - PCS_IOTHUB_CONNSTRING
73 | - PCS_AUTH_ISSUER
74 | - PCS_AUTH_AUDIENCE
75 | - PCS_APPLICATION_SECRET
76 | - PCS_STORAGEADAPTER_WEBSERVICE_URL=http://storageadapter:9022/v1
77 | # This could be used to mount custom device models into the simulation
78 | #volumes:
79 | # - ./sample-volume:/app/data:ro
80 |
81 | telemetry:
82 | image: azureiotpcs/telemetry-java:latest
83 | depends_on:
84 | - storageadapter
85 | ports:
86 | - "9004:9004"
87 | environment:
88 | - PCS_TELEMETRY_DOCUMENTDB_CONNSTRING
89 | - PCS_AUTH_ISSUER
90 | - PCS_AUTH_AUDIENCE
91 | - PCS_APPLICATION_SECRET
92 | - PCS_STORAGEADAPTER_WEBSERVICE_URL=http://storageadapter:9022/v1
93 |
94 | config:
95 | image: azureiotpcs/pcs-config-java:latest
96 | depends_on:
97 | - storageadapter
98 | - devicesimulation
99 | - telemetry
100 | ports:
101 | - "9005:9005"
102 | environment:
103 | - PCS_BINGMAP_KEY
104 | - PCS_AUTH_ISSUER
105 | - PCS_AUTH_AUDIENCE
106 | - PCS_APPLICATION_SECRET
107 | - PCS_STORAGEADAPTER_WEBSERVICE_URL=http://storageadapter:9022/v1
108 | - PCS_DEVICESIMULATION_WEBSERVICE_URL=http://devicesimulation:9003/v1
109 | - PCS_TELEMETRY_WEBSERVICE_URL=http://telemetry:9004/v1
110 |
111 | storageadapter:
112 | image: azureiotpcs/pcs-storage-adapter-java:latest
113 | ports:
114 | - "9022:9022"
115 | environment:
116 | - PCS_STORAGEADAPTER_DOCUMENTDB_CONNSTRING
117 | - PCS_AUTH_ISSUER
118 | - PCS_AUTH_AUDIENCE
119 | - PCS_APPLICATION_SECRET
120 |
121 | telemetryagent:
122 | image: azureiotpcs/telemetry-agent-java:latest
123 | depends_on:
124 | - telemetry
125 | - iothubmanager
126 | ports:
127 | - "9023:9023"
128 | environment:
129 | - PCS_TELEMETRYAGENT_DOCUMENTDB_CONNSTRING
130 | # For more info about IoT Hub react settings see
131 | # https://github.com/Azure/toketi-iothubreact#iothub-configuration
132 | - PCS_IOTHUBREACT_AZUREBLOB_ACCOUNT
133 | - PCS_IOTHUBREACT_AZUREBLOB_KEY
134 | - PCS_IOTHUBREACT_AZUREBLOB_ENDPOINT_SUFFIX
135 | - PCS_IOTHUBREACT_HUB_NAME
136 | - PCS_IOTHUBREACT_HUB_ENDPOINT
137 | - PCS_IOTHUBREACT_HUB_PARTITIONS
138 | - PCS_IOTHUBREACT_ACCESS_CONNSTRING
139 | - PCS_AUTH_ISSUER
140 | - PCS_AUTH_AUDIENCE
141 | - PCS_APPLICATION_SECRET
142 | - PCS_TELEMETRY_WEBSERVICE_URL=http://telemetry:9004/v1
143 | - PCS_CONFIG_WEBSERVICE_URL=http://config:9005/v1
144 | - PCS_IOTHUBMANAGER_WEBSERVICE_URL=http://iothubmanager:9002/v1
145 |
--------------------------------------------------------------------------------
/scripts/docker/run:
--------------------------------------------------------------------------------
1 | echo "Starting at https://localhost:10443"
2 | echo
3 | echo "Note:"
4 | echo " * When running locally, the service might run with an invalid SSL cert"
5 | echo " * The service requires some configuration files hosted under /app"
6 | echo " Edit docker-compose.yml to use a different path"
7 | echo
8 |
9 | read -t 10 -p "Press ENTER to start or wait ten seconds for the services to start..."
10 |
11 | docker-compose up
12 |
--------------------------------------------------------------------------------
/scripts/git/.functions.sh:
--------------------------------------------------------------------------------
1 | header() {
2 | echo -e "\n### $1"
3 | }
4 |
5 | error() {
6 | echo -e "$1"
7 | }
8 |
--------------------------------------------------------------------------------
/scripts/git/pre-commit-runner.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 |
5 | # Path relative to .git/hooks/
6 | APP_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && cd .. && pwd )/"
7 | source "$APP_HOME/scripts/git/pre-commit.sh"
8 |
--------------------------------------------------------------------------------
/scripts/git/pre-commit.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 | APP_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && cd .. && pwd )/"
5 | source "$APP_HOME/scripts/git/.functions.sh"
6 |
7 | cd $APP_HOME
8 | echo "Current folder: `pwd`"
9 |
10 | if git rev-parse --verify HEAD >/dev/null 2>&1 ; then
11 | against=HEAD
12 | else
13 | # Initial commit: diff against an empty tree object
14 | against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
15 | fi
16 |
17 | check_filenames() {
18 | header "Checking filenames..."
19 |
20 | # Redirect output to stderr.
21 | exec 1>&2
22 |
23 | # Cross platform projects tend to avoid non-ASCII filenames; prevent
24 | # them from being added to the repository. We exploit the fact that the
25 | # printable range starts at the space character and ends with tilde.
26 | # Note that the use of brackets around a tr range is ok here, (it's
27 | # even required, for portability to Solaris 10's /usr/bin/tr), since
28 | # the square bracket bytes happen to fall in the designated range.
29 | set +e
30 | if test $(git diff --cached --name-only --diff-filter=A -z $against | LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 ; then
31 | error "Attempt to add a non-ASCII file name. This can cause problems on other platforms."
32 | exit 1
33 | fi
34 | set -e
35 | }
36 |
37 | check_whitespaces() {
38 | header "Checking white spaces and line separators..."
39 | git diff-index --check --cached $against --
40 | }
41 |
42 | check_do_not_commit() {
43 | PATTERN1="DONOT"
44 | PATTERN1="${PATTERN1}COMMIT"
45 | PATTERN2="DO NOT"
46 | PATTERN2="${PATTERN2} COMMIT"
47 | PATTERN3="DONT"
48 | PATTERN3="${PATTERN3}COMMIT"
49 | PATTERN4="DONT"
50 | PATTERN4="${PATTERN4} COMMIT"
51 | PATTERN5="DON'T"
52 | PATTERN5="${PATTERN5} COMMIT"
53 |
54 | header "Checking diff for comments containing '${PATTERN1}'..."
55 |
56 | set +e
57 |
58 | PATT="^\+.*${PATTERN1}.*$"
59 | diffstr=`git diff --cached $against | grep -ie "$PATT"`
60 | if [[ -n "$diffstr" ]]; then
61 | error "You have left '${PATTERN1}' in your changes, you can't commit until it has been removed."
62 | exit 1
63 | fi
64 |
65 | PATT="^\+.*${PATTERN2}.*$"
66 | diffstr=`git diff --cached $against | grep -ie "$PATT"`
67 | if [[ -n "$diffstr" ]]; then
68 | error "You have left '${PATTERN2}' in your changes, you can't commit until it has been removed."
69 | exit 1
70 | fi
71 |
72 | PATT="^\+.*${PATTERN3}.*$"
73 | diffstr=`git diff --cached $against | grep -ie "$PATT"`
74 | if [[ -n "$diffstr" ]]; then
75 | error "You have left '${PATTERN3}' in your changes, you can't commit until it has been removed."
76 | exit 1
77 | fi
78 |
79 | PATT="^\+.*${PATTERN4}.*$"
80 | diffstr=`git diff --cached $against | grep -ie "$PATT"`
81 | if [[ -n "$diffstr" ]]; then
82 | error "You have left '${PATTERN4}' in your changes, you can't commit until it has been removed."
83 | exit 1
84 | fi
85 |
86 | PATT="^\+.*${PATTERN5}.*$"
87 | diffstr=`git diff --cached $against | grep -ie "$PATT"`
88 | if [[ -n "$diffstr" ]]; then
89 | error "You have left '${PATTERN5}' in your changes, you can't commit until it has been removed."
90 | exit 1
91 | fi
92 |
93 | set -e
94 | }
95 |
96 | verify_build() {
97 | header "Verifying build..."
98 |
99 | cd $APP_HOME/scripts
100 | ./build
101 |
102 | if [ $? -ne 0 ]; then
103 | error "Some tests failed."
104 | exit 1
105 | fi
106 | }
107 |
108 | check_filenames
109 | check_whitespaces
110 | check_do_not_commit
111 | verify_build
112 |
--------------------------------------------------------------------------------
/scripts/git/release.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Copyright (c) Microsoft. All rights reserved.
3 | # Note: Windows Bash doesn't support shebang extra params
4 | set -e
5 |
6 | while [ "$#" -gt 0 ]; do
7 | case "$1" in
8 | --version) VERSION="$2" ;;
9 | --git_access_token) GIT_ACCESS_TOKEN="$2" ;;
10 | --docker_user) DOCKER_USER="$2" ;;
11 | --docker_pwd) DOCKER_PWD="$2" ;;
12 | --from_docker_namespace) FROM_DOCKER_NAMESPACE="$2" ;;
13 | --to_docker_namespace) TO_DOCKER_NAMESPACE="$2" ;;
14 | --docker_tag) DOCKER_TAG="$2" ;;
15 | --description) DESCRIPTION="$2" ;;
16 | --pre_release) PRE_RELEASE="$2" ;;
17 | --local) LOCAL="$2" ;;
18 | esac
19 | shift
20 | done
21 |
22 | # Set default values for optional parameters
23 | FROM_DOCKER_NAMESPACE=${FROM_DOCKER_NAMESPACE:-azureiotpcs}
24 | TO_DOCKER_NAMESPACE=${TO_DOCKER_NAMESPACE:-azureiotpcs}
25 | DOCKER_TAG=${DOCKER_TAG:-testing}
26 | DESCRIPTION=${DESCRIPTION:-''}
27 | PRE_RELEASE=${PRE_RELEASE:-false}
28 | LOCAL=${LOCAL:-''}
29 |
30 | APP_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && cd .. && pwd )/"
31 |
32 | NC="\033[0m" # no color
33 | CYAN="\033[1;36m" # light cyan
34 | YELLOW="\033[1;33m" # yellow
35 | RED="\033[1;31m" # light red
36 |
37 | failed() {
38 | SUB_MODULE=$1
39 | echo -e "${RED}Cannot find directory $SUB_MODULE${NC}"
40 | exit 1
41 | }
42 |
43 | usage() {
44 | echo -e "${RED}ERROR: $1 is a required option${NC}"
45 | echo "Usage: ./release"
46 | echo -e 'Options:
47 | --version Version of this release (required)
48 | --git_access_token Git access token to push tag (required)
49 | --docker_user Username to login docker hub (required)
50 | --docker_pwd Password to login docker hub (required)
51 | --from_docker_namespace Source namespace of docker image (default:azureiotpcs)
52 | --to_docker_namespace Target namespace of docker image (default:azureiotpcs)
53 | --docker_tag Source tag of docker image (default:testing)
54 | --description Description of this release (default:empty)
55 | --pre_release Publish as non-production release on github (default:false)
56 | --local Clean up the local repo at first (default:empty)
57 | '
58 | exit 1
59 | }
60 |
61 | check_input() {
62 | if [ ! -n "$VERSION" ]; then
63 | usage "version"
64 | fi
65 | if [ ! -n "$GIT_ACCESS_TOKEN" ]; then
66 | usage "git_access_token"
67 | fi
68 | if [ ! -n "$DOCKER_USER" ]; then
69 | usage "docker_user"
70 | fi
71 | if [ ! -n "$DOCKER_PWD" ]; then
72 | usage "docker_pwd"
73 | fi
74 | echo $DOCKER_PWD | docker login -u $DOCKER_USER --password-stdin
75 | }
76 |
77 | tag_release_repo() {
78 | SUB_MODULE=$1
79 | REPO_NAME=$2
80 | DESCRIPTION=$3
81 |
82 | echo
83 | echo -e "${CYAN}==================================== Start: Tagging the $REPO_NAME repo ====================================${NC}"
84 | echo
85 | echo -e "Current working directory ${CYAN}$APP_HOME$SUB_MODULE${NC}"
86 | echo
87 | cd $APP_HOME$SUB_MODULE || failed $SUB_MODULE
88 |
89 | if [ -n "$LOCAL" ]; then
90 | echo "Cleaning the repo"
91 | git reset --hard origin/master
92 | git clean -xdf
93 | fi
94 | git checkout master
95 | git pull --all --prune
96 | git fetch --tags
97 |
98 | git tag --force $VERSION
99 | git push https://$GIT_ACCESS_TOKEN@github.com/Azure/$REPO_NAME.git $VERSION
100 |
101 | echo
102 | echo -e "${CYAN}==================================== End: Tagging $REPO_NAME repo ====================================${NC}"
103 | echo
104 |
105 | echo
106 | echo -e "${CYAN}==================================== Start: Release for $REPO_NAME ====================================${NC}"
107 | echo
108 |
109 | # For documentation https://help.github.com/articles/creating-releases/
110 | DATA="{
111 | \"tag_name\": \"$VERSION\",
112 | \"target_commitish\": \"master\",
113 | \"name\": \"$VERSION\",
114 | \"body\": \"$DESCRIPTION\",
115 | \"draft\": false,
116 | \"prerelease\": $PRE_RELEASE
117 | }"
118 |
119 | curl -X POST --data "$DATA" https://api.github.com/repos/Azure/$REPO_NAME/releases?access_token=$GIT_ACCESS_TOKEN
120 | echo
121 | echo -e "${CYAN}==================================== End: Release for $REPO_NAME ====================================${NC}"
122 | echo
123 | }
124 |
125 | publish_docker_containers()
126 | {
127 | DOCKER_CONTAINER_NAME=$1
128 | SUB_MODULE=$2
129 |
130 | if [ "$SUB_MODULE" == "reverse-proxy" ]; then
131 | cd $APP_HOME$SUB_MODULE || failed $SUB_MODULE
132 | if [ -n "$LOCAL" ]; then
133 | echo "Cleaning the repo"
134 | git reset --hard origin/master
135 | git clean -xdf
136 | fi
137 | git checkout master
138 | git pull --all --prune
139 |
140 | echo
141 | echo -e "${CYAN}==================================== Start: Building $DOCKER_CONTAINER_NAME ====================================${NC}"
142 | echo
143 |
144 | BUILD_PATH="build"
145 | # Building docker containers
146 | /bin/bash $APP_HOME$SUB_MODULE/$BUILD_PATH
147 |
148 | echo
149 | echo -e "${CYAN}==================================== End: Building $DOCKER_CONTAINER_NAME ====================================${NC}"
150 | echo
151 | else
152 | # Pull containers
153 | echo -e "${CYAN}Pulling $FROM_DOCKER_NAMESPACE/$DOCKER_CONTAINER_NAME:$DOCKER_TAG${NC}"
154 | echo
155 | docker pull $FROM_DOCKER_NAMESPACE/$DOCKER_CONTAINER_NAME:$DOCKER_TAG
156 | fi
157 |
158 | # Tag containers
159 | echo -e "${CYAN}Tagging $FROM_DOCKER_NAMESPACE/$DOCKER_CONTAINER_NAME:$DOCKER_TAG ==> $TO_DOCKER_NAMESPACE/$DOCKER_CONTAINER_NAME:$VERSION${NC}"
160 | echo
161 | docker tag $FROM_DOCKER_NAMESPACE/$DOCKER_CONTAINER_NAME:$DOCKER_TAG $TO_DOCKER_NAMESPACE/$DOCKER_CONTAINER_NAME:$VERSION
162 |
163 | # Push containers
164 | echo -e "${CYAN}Pusing container $TO_DOCKER_NAMESPACE/$DOCKER_CONTAINER_NAME:$VERSION${NC}"
165 | docker push $TO_DOCKER_NAMESPACE/$DOCKER_CONTAINER_NAME:$VERSION
166 | }
167 |
168 | check_input
169 |
170 | # Publish Java Microservices docker containers
171 | publish_docker_containers pcs-config-java
172 | publish_docker_containers iothub-manager-java
173 | publish_docker_containers pcs-storage-adapter-java
174 | publish_docker_containers telemetry-java
175 |
176 | # Release and tag top-level java repository with latest version
177 | tag_release_repo services remote-monitoring-services-java
178 | tag_release_repo "" azure-iot-pcs-remote-monitoring-java $DESCRIPTION
179 |
180 | # Done through dotnet release script
181 | # tag_release_repo webui pcs-remote-monitoring-webui
182 | # PCS CLI
183 | # tag_release_repo cli pcs-cli
184 | # Top Level repo
185 | # publish_docker_containers pcs-remote-monitoring-webui
186 | # publish_docker_containers remote-monitoring-nginx reverse-proxy
187 |
188 | # Only dotnet exists
189 | # publish_docker_containers pcs-diagnostics-dotnet
190 | # publish_docker_containers pcs-auth-dotnet
191 | # publish_docker_containers device-simulation-dotnet
192 | # publish_docker_containers asa-manager-dotnet
193 |
194 | set +e
--------------------------------------------------------------------------------
/scripts/git/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 | APP_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && cd .. && pwd )/"
5 |
6 | failed() {
7 | echo "Git hooks setup failed"
8 | exit 1
9 | }
10 |
11 | cd $APP_HOME/.git || failed
12 | mkdir -p hooks || failed
13 | cd hooks || failed
14 |
15 | echo "Adding pre-commit hook..."
16 | rm -f pre-commit
17 | cp -p $APP_HOME/scripts/git/pre-commit-runner.sh ./pre-commit || failed
18 |
19 | echo "Done."
20 |
--------------------------------------------------------------------------------
/scripts/git/setup.cmd:
--------------------------------------------------------------------------------
1 | @ECHO off
2 | setlocal
3 |
4 | :: strlen("\scripts\git\") => 13
5 | SET APP_HOME=%~dp0
6 | SET APP_HOME=%APP_HOME:~0,-13%
7 |
8 | cd %APP_HOME%
9 |
10 | echo Adding pre-commit hook...
11 |
12 | mkdir .git\hooks\ 2> nul
13 | del /F .git\hooks\pre-commit 2> nul
14 | copy scripts\git\pre-commit-runner.sh .git\hooks\pre-commit
15 | IF NOT ERRORLEVEL 0 GOTO FAIL
16 |
17 | echo Done.
18 |
19 | :: - - - - - - - - - - - - - -
20 | goto :END
21 |
22 | :FAIL
23 | echo Command failed
24 | endlocal
25 | exit /B 1
26 |
27 | :END
28 | endlocal
--------------------------------------------------------------------------------
/scripts/iothub/.functions.sh:
--------------------------------------------------------------------------------
1 | COL_NO="\033[0m" # no color
2 | COL_ERR="\033[1;31m" # light red
3 | COL_H1="\033[1;33m" # yellow
4 | COL_H2="\033[1;36m" # light cyan
5 |
6 | header() {
7 | echo -e "${COL_H1}\n### $1 ${COL_NO}\n"
8 | }
9 |
10 | announce() {
11 | echo -e "${COL_H2}\n> $1 ${COL_NO}"
12 | }
13 |
14 | error() {
15 | echo -e "${COL_ERR}$1 ${COL_NO}"
16 | }
17 |
18 | error_and_exit() {
19 | echo -e "${COL_ERR}$1 ${COL_NO}"
20 | exit -1
21 | }
22 |
23 | user_exit() {
24 | echo -e "${COL_H2}\nStopped${COL_NO}"
25 | exit -2
26 | }
27 |
28 | check_dependencies() {
29 | TEST=$(which jq)
30 | if [[ -z "$TEST" ]]; then
31 | error "ERROR: 'jq' command not found. Install 'jq' first."
32 | error "with debian/ubuntu: apt-get install jq"
33 | error "with homebrew: brew install jq"
34 | exit -1
35 | fi
36 |
37 | TEST=$(which az)
38 | if [[ -z "$TEST" ]]; then
39 | error "ERROR: 'az' command not found. Install Azure CLI first."
40 | error "how to: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli"
41 | error "with bash: curl -L https://aka.ms/InstallAzureCli | bash"
42 | exit -1
43 | fi
44 |
45 | TEST=$(which azure)
46 | if [[ -z "$TEST" ]]; then
47 | error "ERROR: 'azure' command not found. Install Azure cross-platform CLI first."
48 | error "with npm: npm install -g azure-cli"
49 | error "with homebrew: brew install azure-cli"
50 | exit -1
51 | fi
52 | }
53 |
54 | login() {
55 | TEST=$(az account list-locations 2>&1)
56 | if [[ "$?" != "0" ]]; then
57 | header "Azure authentication required"
58 | announce "After the authentication, this machine will be allowed to execute Azure commands on your behalf."
59 | announce "At any moment, you can use 'az logout' to close the authenticated session."
60 | echo
61 |
62 | az login
63 | fi
64 | }
65 |
66 | show_hub_details() {
67 | header "Azure IoT Hub details"
68 |
69 | DATA=$(az iot hub show --name "$2")
70 |
71 | echo "Name: $(echo $DATA | jq .name)"
72 | echo "Location: $(echo $DATA | jq .location)"
73 | echo "SKU: $(echo $DATA | jq .sku.name)"
74 | echo "Units: $(echo $DATA | jq .sku.capacity)"
75 |
76 | echo "D2C Events endpoint: $(echo $DATA | jq .properties.eventHubEndpoints.events.endpoint)"
77 | echo "D2C Partitions: $(echo $DATA | jq .properties.eventHubEndpoints.events.partitionCount)"
78 | echo "D2C Events retention: $(echo $DATA | jq .properties.eventHubEndpoints.events.retentionTimeInDays) days"
79 |
80 | echo "C2D Hostname: $(echo $DATA | jq .properties.hostName)"
81 | echo "C2D Messages retention: $(echo $DATA | jq .properties.cloudToDevice.defaultTtlAsIso8601)"
82 |
83 | header "Quota"
84 |
85 | DATA=$(az iot hub show-quota-metrics --name "$2")
86 | echo "Messages: $(echo $DATA | jq '.[0].currentValue')/$(echo $DATA | jq '.[0].maxValue')"
87 | echo "Devices: $(echo $DATA | jq '.[1].currentValue')/$(echo $DATA | jq '.[1].maxValue')"
88 |
89 | header "Azure IoT Hub keys"
90 |
91 | azure iothub key list "$1" "$2"
92 | }
93 |
94 | do_select_subscription() {
95 | header "Select subscription"
96 |
97 | azure account list
98 |
99 | echo
100 | TEMP=""
101 | while [[ -z "$TEMP" ]]; do
102 | echo -n "Enter subscription ID: "
103 | read TEMP
104 | done
105 |
106 | azure account set "$TEMP" || error_and_exit "Unable to select the requested subscription."
107 | }
108 |
109 | select_subscription() {
110 | header "Azure subscription"
111 |
112 | echo -e "Reading account...\n"
113 | TEST0=$(az account list)
114 | TEST1=$(echo $TEST0 | grep isDefault|grep true)
115 | if [[ -z "$TEST1" ]]; then
116 | echo "No subscription selected"
117 | do_select_subscription
118 | else
119 | echo "Current subscription:"
120 | echo $TEST0 | jq '.[] | select(.isDefault == true)' | jq '{name: .name, id: .id, user: .user.name}' | jq .
121 | echo -e "\nDo you want to change to a different subscription?"
122 | PS3=">> "
123 | select YNC in No Yes; do
124 | case $YNC in
125 | Yes ) do_select_subscription; break;;
126 | No ) break;;
127 | esac
128 | done
129 | fi
130 | }
131 |
--------------------------------------------------------------------------------
/scripts/iothub/create-hub.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
5 | source "$DIR/.functions.sh"
6 |
7 | if [[ "$1" == "-a" || "$1" == "--all-options" ]]; then
8 | ADVANCED=true
9 | else
10 | ADVANCED=false
11 | fi
12 |
13 | SUBSCRIPTION=""
14 | HUB_NAME=""
15 | RESOURCE_GROUP=""
16 | NEW_RESOURCE_GROUP="false"
17 | LOCATION=""
18 | SKU=""
19 | MAXUNITS=""
20 | UNITS=""
21 | D2C_PARTITIONS=""
22 | D2C_TTL=""
23 | C2D_ATTEMPTS=""
24 | C2D_TTL=""
25 | C2D_FEEDBACK_LOCK=""
26 | C2D_FEEDBACK_TTL=""
27 | C2D_FEEDBACK_ATTEMPTS=""
28 |
29 | ask_hub_name() {
30 | header "New Azure IoT Hub"
31 | HUB_NAME=""
32 |
33 | while [[ -z "$HUB_NAME" ]]; do
34 | echo -n "Enter IoT Hub name: "
35 | read HUB_NAME
36 | done
37 | }
38 |
39 | select_resource_group() {
40 | header "Resource group"
41 |
42 | echo "Existing resource groups"
43 |
44 | azure group list
45 |
46 | echo
47 | announce "You can re-use an existing group or enter a new name to create a new resource group."
48 | echo
49 | RESOURCE_GROUP=""
50 | while [[ -z "$RESOURCE_GROUP" ]]; do
51 | echo -n "Enter resource group name: "
52 | read RESOURCE_GROUP
53 | done
54 |
55 | NEW_RESOURCE_GROUP="false"
56 | TEST=$(azure group list | grep -i "$RESOURCE_GROUP")
57 | if [[ -z "$TEST" ]]; then
58 | NEW_RESOURCE_GROUP="true"
59 | fi
60 | }
61 |
62 | select_location() {
63 | header "Azure region"
64 |
65 | # TODO: az account list-locations + filter for IoT Hub
66 | echo -e "Select the location where to create the hub:"
67 | PS3=">> "
68 | select LOCATION in eastus westus westus2 westcentralus northeurope westeurope eastasia southeastasia japaneast japanwest australiaeast australiasoutheast; do
69 | break;
70 | done
71 | }
72 |
73 | select_sku_and_units() {
74 | header "Pricing and Scale Tier"
75 |
76 | echo "F1: 8k messages/unit/day (free)"
77 | echo "S1: 400k messages/unit/day"
78 | echo "S2: 6M messages/unit/day"
79 | echo "S3: 300M messages/unit/day"
80 |
81 | echo -e "\nSelect pricing and scale:"
82 | PS3=">> "
83 | select SKU in F1 S1 S2 S3; do
84 | case $SKU in
85 | F1 ) MAXUNITS=1; break;;
86 | S1 ) MAXUNITS=200; break;;
87 | S2 ) MAXUNITS=200; break;;
88 | S3 ) MAXUNITS=10; break;;
89 | esac
90 | done
91 |
92 | UNITS="1"
93 | if [[ "$SKU" != "F1" ]]; then
94 | echo -n -e "\nHow many units? (1..${MAXUNITS}) [${UNITS}]: "
95 | read TEMP
96 | if [[ ! -z "$TEMP" ]]; then UNITS="$TEMP"; fi
97 | fi
98 | }
99 |
100 | ask_d2c_partitions() {
101 | D2C_PARTITIONS="2" # 2..128 (2 for F1)
102 | if [[ "$ADVANCED" == "false" ]]; then return 0; fi
103 |
104 | if [[ "$SKU" != "F1" ]]; then
105 | echo -n "How many partitions? (1..128) [${D2C_PARTITIONS}]: "
106 | read TEMP
107 | if [[ ! -z "$TEMP" ]]; then D2C_PARTITIONS="$TEMP"; fi
108 | fi
109 | }
110 |
111 | ask_d2c_retention() {
112 | D2C_TTL="1" # 1..7 days
113 | if [[ "$ADVANCED" == "false" ]]; then return 0; fi
114 |
115 | echo -n "How many days before device-to-cloud messages expire? (1..7) [${D2C_TTL}]: "
116 | read TEMP
117 | if [[ ! -z "$TEMP" ]]; then D2C_TTL="$TEMP"; fi
118 | }
119 |
120 | ask_c2d_attempts() {
121 | C2D_ATTEMPTS="10" # 1..100 count
122 | if [[ "$ADVANCED" == "false" ]]; then return 0; fi
123 |
124 | echo -n "How many attempts to deliver a cloud-to-device message? (1..100) [${C2D_ATTEMPTS}]: "
125 | read TEMP
126 | if [[ ! -z "$TEMP" ]]; then C2D_ATTEMPTS="$TEMP"; fi
127 | }
128 |
129 | ask_c2d_ttl() {
130 | # PnYnMnDTnHnMnS
131 | C2D_TTL="PT1H" # 1 min .. 2 days
132 | if [[ "$ADVANCED" == "false" ]]; then return 0; fi
133 |
134 | echo -n "How long before cloud-to-device messages expire? (ISO8601: 1 min .. 2 days) [${C2D_TTL}]: "
135 | read TEMP
136 | if [[ ! -z "$TEMP" ]]; then C2D_TTL="$TEMP"; fi
137 | }
138 |
139 | ask_c2d_feedback_lock() {
140 | # PnYnMnDTnHnMnS
141 | C2D_FEEDBACK_LOCK="PT1M" # 5 secs .. 5 mins
142 | if [[ "$ADVANCED" == "false" ]]; then return 0; fi
143 |
144 | echo -n "How long before cloud-to-device feedback messages lock expire? (ISO8601: 5 secs .. 5 mins) [${C2D_FEEDBACK_LOCK}]: "
145 | read TEMP
146 | if [[ ! -z "$TEMP" ]]; then C2D_FEEDBACK_LOCK="$TEMP"; fi
147 | }
148 |
149 | ask_c2d_feedback_ttl() {
150 | # PnYnMnDTnHnMnS
151 | C2D_FEEDBACK_TTL="PT1M" # 1 min .. 2days
152 | if [[ "$ADVANCED" == "false" ]]; then return 0; fi
153 |
154 | echo -n "How long before cloud-to-device feedback messages expire? (ISO8601: 1 min .. 2days) [${C2D_FEEDBACK_TTL}]: "
155 | read TEMP
156 | if [[ ! -z "$TEMP" ]]; then C2D_FEEDBACK_TTL="$TEMP"; fi
157 | }
158 |
159 | ask_c2d_feedback_attempts() {
160 | C2D_FEEDBACK_ATTEMPTS="1" # 1..100 count
161 | if [[ "$ADVANCED" == "false" ]]; then return 0; fi
162 |
163 | echo -n "How many attempts to deliver a cloud-to-device feedback message? (1..100) [${C2D_FEEDBACK_ATTEMPTS}]: "
164 | read TEMP
165 | if [[ ! -z "$TEMP" ]]; then C2D_FEEDBACK_ATTEMPTS="$TEMP"; fi
166 | }
167 |
168 | advanced() {
169 | if [[ "$ADVANCED" == "true" ]]; then
170 | header "Other settings";
171 | else
172 | announce "Using default settings. Use '--all-options' to manually set all the hub options."
173 | fi
174 |
175 | ask_d2c_partitions
176 | ask_d2c_retention
177 | ask_c2d_attempts
178 | ask_c2d_ttl
179 | ask_c2d_feedback_lock
180 | ask_c2d_feedback_ttl
181 | ask_c2d_feedback_attempts
182 | }
183 |
184 | create_hub() {
185 | header "Create '$HUB_NAME' in '$LOCATION'"
186 |
187 | if [[ $NEW_RESOURCE_GROUP == "true" ]]; then
188 | azure group create "$RESOURCE_GROUP" "$LOCATION" || error_and_exit "Unable to create resource group."
189 | fi
190 |
191 | azure iothub create "$RESOURCE_GROUP" "$HUB_NAME" "$LOCATION" "$SKU" "$UNITS" \
192 | --enable-dm \
193 | --d2c-partitions "$D2C_PARTITIONS" \
194 | --d2c-retention-time-in-days "$D2C_TTL" \
195 | --c2d-max-delivery-count "$C2D_ATTEMPTS" \
196 | --c2d-ttl "$C2D_TTL" \
197 | --feedback-lock-duration "$C2D_FEEDBACK_LOCK" \
198 | --feedback-ttl "$C2D_FEEDBACK_TTL" \
199 | --feedback-max-delivery-count "$C2D_FEEDBACK_ATTEMPTS" \
200 | || error_and_exit "Unable to create IoT Hub"
201 | }
202 |
203 | confirm() {
204 | header "Summary"
205 |
206 | echo "Azure IoT Hub name: ${HUB_NAME}"
207 | echo "Resource group name: ${RESOURCE_GROUP} (new: ${NEW_RESOURCE_GROUP})"
208 | echo "Azure region: ${LOCATION}"
209 | echo "Pricing and Scaling SKU ${SKU}"
210 | echo "Capacity units: ${UNITS}"
211 | echo "D2C events partitions: ${D2C_PARTITIONS}"
212 | echo "D2C events TTL: ${D2C_TTL} days"
213 | echo "C2D messages TTL: ${C2D_TTL}"
214 | echo "C2D message delivery attempts: ${C2D_ATTEMPTS}"
215 | echo "C2D feedback TTL: ${C2D_FEEDBACK_TTL}"
216 | echo "C2D feedback delivery attempts: ${C2D_FEEDBACK_ATTEMPTS}"
217 | echo "C2D feedback lock TTL: ${C2D_FEEDBACK_LOCK}"
218 | echo
219 |
220 | echo "Proceed?"
221 | PS3=">> "
222 | select SKU in Yes No; do
223 | case $SKU in
224 | No ) user_exit;;
225 | Yes ) break;;
226 | esac
227 | done
228 | }
229 |
230 | main() {
231 | check_dependencies
232 | login
233 |
234 | ask_hub_name
235 | select_subscription
236 | select_resource_group
237 | select_location
238 | select_sku_and_units
239 | advanced
240 | confirm
241 | create_hub
242 | show_hub_details "$RESOURCE_GROUP" "$HUB_NAME"
243 |
244 | announce "Tip: to show the hub details, run: ./show-hub.sh $RESOURCE_GROUP $HUB_NAME"
245 | }
246 |
247 | main
248 |
--------------------------------------------------------------------------------
/scripts/iothub/list-hubs.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
5 | source "$DIR/.functions.sh"
6 |
7 | main() {
8 | check_dependencies
9 | login
10 |
11 | header "Azure IoT Hubs in the current subscription"
12 | az iot hub list | jq '.[] | {name: .name, resourcegroup: .resourcegroup, location: .location, subscription: .subscriptionid}' | jq .
13 | }
14 |
15 | main
16 |
--------------------------------------------------------------------------------
/scripts/iothub/list-subscriptions.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
5 | source "$DIR/.functions.sh"
6 |
7 | main() {
8 | check_dependencies
9 | login
10 |
11 | header "Azure subscriptions"
12 | azure account list
13 | #az account list | jq '.[] | {name: .name, id: .id, current: .isDefault}' | jq .
14 | }
15 |
16 | main
17 |
--------------------------------------------------------------------------------
/scripts/iothub/select-subscription.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
5 | source "$DIR/.functions.sh"
6 |
7 | SUBSCRIPTION_ID="$1"
8 |
9 | check_input() {
10 | if [[ -z "$SUBSCRIPTION_ID" ]]; then
11 | announce "Usage: ./select-subscription.sh SUBSCRIPTION_ID"
12 | echo "Use './list-subscriptions.sh' to see the list of subscriptions."
13 | fi
14 | }
15 |
16 | main() {
17 | check_input
18 | check_dependencies
19 | login
20 |
21 | if [[ ! -z "$SUBSCRIPTION_ID" ]]; then
22 | header "Changing current subscription"
23 | #az account set --subscription "$SUBSCRIPTION_ID"
24 | azure account set "$SUBSCRIPTION_ID"
25 | else
26 | select_subscription
27 | fi
28 | }
29 |
30 | main
31 |
--------------------------------------------------------------------------------
/scripts/iothub/show-hub.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
5 | source "$DIR/.functions.sh"
6 |
7 | RESOURCE_GROUP="$1"
8 | HUB_NAME="$2"
9 |
10 | check_input() {
11 | if [[ -z "$RESOURCE_GROUP" || -z "$HUB_NAME" ]]; then
12 | announce "Usage: ./show-hub.sh RESOURCE_GROUP HUB_NAME"
13 | echo "Use './list-hubs.sh' to see the list of hubs."
14 | exit -1
15 | fi
16 | }
17 |
18 | main() {
19 | check_input
20 | check_dependencies
21 | login
22 | show_hub_details "$RESOURCE_GROUP" "$HUB_NAME"
23 | }
24 |
25 | main
26 |
--------------------------------------------------------------------------------
/scripts/local/.env:
--------------------------------------------------------------------------------
1 | # -----------------------------------------------------------------------------
2 | # Required environment variables for local setup
3 | # -----------------------------------------------------------------------------
4 | # 1. Locate strings for each section below
5 | # 2. Paste your strings in the required format, DO NOT add quotation marks
6 | # 3. Save and run docker-compose up from the scripts/local folder
7 | # -----------------------------------------------------------------------------
8 |
9 | # -----------------------------------------------------------------------------
10 | # IoTHub connection string:
11 | # {Your IoT Hub} > Shared access policies > Connection string -- primary key
12 | # Note: use this value for both environment variables below
13 | #
14 | # Example:
15 | # PCS_IOTHUBREACT_ACCESS_CONNSTRING=HostName=iothub-test123.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=12345=
16 | # PCS_IOTHUB_CONNSTRING=HostName=iothub-test123.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=12345=
17 | # -----------------------------------------------------------------------------
18 | PCS_IOTHUBREACT_ACCESS_CONNSTRING=
19 | PCS_IOTHUB_CONNSTRING=
20 |
21 | # -----------------------------------------------------------------------------
22 | # IoTHub Info can be found in the Azure portal at:
23 | # {Your IoT Hub} > Endpoints > events
24 | #
25 | # Example:
26 | # PCS_IOTHUBREACT_HUB_NAME=iothub-test123
27 | # PCS_IOTHUBREACT_HUB_ENDPOINT=Endpoint=sb://iothub-foo-iothub-bar-12345-12345.servicebus.windows.net/;SharedAccessKeyName=iothubowner;SharedAccessKey=12345=
28 | # PCS_IOTHUBREACT_HUB_PARTITIONS=4
29 | # -----------------------------------------------------------------------------
30 | PCS_IOTHUBREACT_HUB_NAME=
31 | PCS_IOTHUBREACT_HUB_ENDPOINT=
32 | PCS_IOTHUBREACT_HUB_PARTITIONS=
33 |
34 | # -----------------------------------------------------------------------------
35 | # Storage Account information:
36 | # {Your storage account} > Access keys
37 | #
38 | # Example:
39 | # PCS_IOTHUBREACT_AZUREBLOB_ACCOUNT=storagetest123
40 | # PCS_IOTHUBREACT_AZUREBLOB_KEY=12345...6789==
41 | # -----------------------------------------------------------------------------
42 | PCS_IOTHUBREACT_AZUREBLOB_ACCOUNT=
43 | PCS_IOTHUBREACT_AZUREBLOB_KEY=
44 |
45 | # -----------------------------------------------------------------------------
46 | # Storage Endpoint Suffix:
47 | # {Your storage account} > Properties > Primary Blob Service Endpoint > value
48 | # in the URI after the "blob." (eg. `core.windows.net`)
49 | #
50 | # Example:
51 | # PCS_IOTHUBREACT_AZUREBLOB_ENDPOINT_SUFFIX=core.windows.net
52 | # -----------------------------------------------------------------------------
53 | PCS_IOTHUBREACT_AZUREBLOB_ENDPOINT_SUFFIX=
54 |
55 | # -----------------------------------------------------------------------------
56 | # DocumentDb Conn String:
57 | # {Your Document DB} > Keys > Primary Connection String
58 | # Note: use this value for all 3 environment variables below
59 | #
60 | # Example:
61 | # PCS_STORAGEADAPTER_DOCUMENTDB_CONNSTRING=AccountEndpoint=https://documentdb-test123.documents.azure.com:443/;AccountKey=12345==;
62 | # PCS_TELEMETRY_DOCUMENTDB_CONNSTRING=AccountEndpoint=https://documentdb-test123.documents.azure.com:443/;AccountKey=12345==;
63 | # PCS_TELEMETRYAGENT_DOCUMENTDB_CONNSTRING=AccountEndpoint=https://documentdb-test123.documents.azure.com:443/;AccountKey=12345==;
64 | # -----------------------------------------------------------------------------
65 | PCS_STORAGEADAPTER_DOCUMENTDB_CONNSTRING=
66 | PCS_TELEMETRY_DOCUMENTDB_CONNSTRING=
67 | PCS_TELEMETRYAGENT_DOCUMENTDB_CONNSTRING=
68 |
69 | # -----------------------------------------------------------------------------
70 | # Auth is disabled for local development
71 | # -----------------------------------------------------------------------------
72 | PCS_AUTH_REQUIRED=false
73 |
74 | # -----------------------------------------------------------------------------
75 | # To add a bing map key, please follow the directions here:
76 | # https://msdn.microsoft.com/library/ff428642.aspx
77 | # -----------------------------------------------------------------------------
78 | PCS_AZUREMAPS_KEY=static
79 |
80 | # -----------------------------------------------------------------------------
81 | # You can allow requests to another domain with the PCS_CORS_WHITELIST, see
82 | # the following link for more information:
83 | # https://docs.microsoft.com/aspnet/web-api/overview/security/enabling-cross-origin-requests-in-web-api
84 | # -----------------------------------------------------------------------------
85 | PCS_CORS_WHITELIST=
86 |
87 | # -----------------------------------------------------------------------------
88 | # Enter any random integer value here.
89 | # -----------------------------------------------------------------------------
90 | PCS_APPLICATION_SECRET=
91 |
92 | # -----------------------------------------------------------------------------
93 | # Azure Streaming Analytics (ASA) information:
94 | # {Your storage account} > Access keys
95 | #
96 | # Example:
97 | # PCS_ASA_DATA_AZUREBLOB_ACCOUNT=storagetest123
98 | # PCS_ASA_DATA_AZUREBLOB_KEY=12345...6789==
99 | # PCS_ASA_DATA_AZUREBLOB_ENDPOINT_SUFFIX=core.windows.net
100 | # PCS_EVENTHUB_CONNSTRING=Endpoint=Endpoint=sb://namespace-abcd1234.servicebus.windows.net/;SharedAccessKeyName=resourceOwner;SharedAccessKey=abcd1234=
101 | # PCS_EVENTHUB_NAME=eventhub-1234
102 | # -----------------------------------------------------------------------------
103 | PCS_ASA_DATA_AZUREBLOB_ACCOUNT=
104 | PCS_ASA_DATA_AZUREBLOB_KEY=
105 | PCS_ASA_DATA_AZUREBLOB_ENDPOINT_SUFFIX=
106 | PCS_EVENTHUB_CONNSTRING=Endpoint=
107 | PCS_EVENTHUB_NAME=
108 |
--------------------------------------------------------------------------------
/scripts/local/config/nginx.conf:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft. All rights reserved.
2 |
3 | # TODO: verify whether the resolver/DNS works (or has no impact) when running with Kubernetes
4 | # TODO: remove logs or move outside of the container
5 |
6 | daemon off;
7 | worker_processes 1;
8 | error_log /app/logs/error.log;
9 | pid /app/logs/nginx.pid;
10 | worker_rlimit_nofile 131072;
11 |
12 | events {
13 | worker_connections 1024;
14 | }
15 |
16 | http {
17 | # Required so that nginx can resolve IPs when working with Docker Compose
18 | resolver 127.0.0.11 ipv6=off;
19 |
20 | include /etc/nginx/mime.types;
21 | default_type text/plain;
22 |
23 | index index.html index.htm;
24 |
25 | log_format upstreaminfo '$remote_addr - '
26 | '[$proxy_add_x_forwarded_for] - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" '
27 | '$request_length $request_time $upstream_addr $upstream_response_length $upstream_response_time $upstream_status';
28 |
29 | access_log /app/logs/access.log upstreaminfo;
30 | error_log /app/logs/error.log;
31 |
32 | server {
33 | listen 10080;
34 | server_name reverseproxy 127.0.0.1;
35 |
36 | # Disable caching behavior for now
37 | # TODO: enable cache for static content later
38 | add_header Cache-Control "no-cache";
39 | expires 0;
40 |
41 | # when serving any content, include a X-Content-Type-Options: nosniff
42 | # header along with the Content-Type: header, to disable content-type
43 | # sniffing on some browsers.
44 | add_header X-Content-Type-Options "nosniff" always;
45 |
46 | # Don't allow the browser to render the page inside a frame/iframe
47 | # and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking
48 | # If you need [i]frames, use SAMEORIGIN or set an uri with ALLOW-FROM uri
49 | # See https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options
50 | add_header X-Frame-Options SAMEORIGIN always;
51 |
52 | set $webui_endpoint "http://webui:10080";
53 | set $auth_endpoint "http://auth:9001";
54 | set $iothubmanager_endpoint "http://iothubmanager:9002";
55 | set $devicesimulation_endpoint "http://devicesimulation:9003";
56 | set $telemetry_endpoint "http://telemetry:9004";
57 | set $config_endpoint "http://config:9005";
58 |
59 | location / {
60 | proxy_pass $webui_endpoint;
61 | proxy_pass_header Authorization;
62 | # TODO ~devis: remove - https://github.com/Azure/azure-iot-pcs-remote-monitoring-dotnet/issues/11
63 | # Public preview only: used to distinguish internal/external traffic
64 | proxy_set_header X-Source external;
65 | proxy_buffering off;
66 | client_max_body_size 0;
67 | proxy_read_timeout 3600s;
68 | proxy_redirect off;
69 | }
70 |
71 | location /auth/ {
72 | rewrite /auth/(.*) /$1 break;
73 | proxy_pass $auth_endpoint;
74 | proxy_pass_header Authorization;
75 | # TODO ~devis: remove - https://github.com/Azure/azure-iot-pcs-remote-monitoring-dotnet/issues/11
76 | # Public preview only: used to distinguish internal/external traffic
77 | proxy_set_header X-Source external;
78 | proxy_buffering off;
79 | client_max_body_size 0;
80 | proxy_read_timeout 3600s;
81 | proxy_redirect off;
82 | }
83 |
84 | location /iothubmanager/ {
85 | rewrite /iothubmanager/(.*) /$1 break;
86 | proxy_pass $iothubmanager_endpoint;
87 | proxy_pass_header Authorization;
88 | # TODO ~devis: remove - https://github.com/Azure/azure-iot-pcs-remote-monitoring-dotnet/issues/11
89 | # Public preview only: used to distinguish internal/external traffic
90 | proxy_set_header X-Source external;
91 | proxy_buffering off;
92 | client_max_body_size 0;
93 | proxy_read_timeout 3600s;
94 | proxy_redirect off;
95 | }
96 |
97 | location /devicesimulation/ {
98 | rewrite /devicesimulation/(.*) /$1 break;
99 | proxy_pass $devicesimulation_endpoint;
100 | proxy_pass_header Authorization;
101 | # TODO ~devis: remove - https://github.com/Azure/azure-iot-pcs-remote-monitoring-dotnet/issues/11
102 | # Public preview only: used to distinguish internal/external traffic
103 | proxy_set_header X-Source external;
104 | proxy_buffering off;
105 | client_max_body_size 0;
106 | proxy_read_timeout 3600s;
107 | proxy_redirect off;
108 | }
109 |
110 | location /telemetry/ {
111 | rewrite /telemetry/(.*) /$1 break;
112 | proxy_pass $telemetry_endpoint;
113 | proxy_pass_header Authorization;
114 | # TODO ~devis: remove - https://github.com/Azure/azure-iot-pcs-remote-monitoring-dotnet/issues/11
115 | # Public preview only: used to distinguish internal/external traffic
116 | proxy_set_header X-Source external;
117 | proxy_buffering off;
118 | client_max_body_size 0;
119 | proxy_read_timeout 3600s;
120 | proxy_redirect off;
121 | }
122 |
123 | location /config/ {
124 | rewrite /config/(.*) /$1 break;
125 | proxy_pass $config_endpoint;
126 | proxy_pass_header Authorization;
127 | # TODO ~devis: remove - https://github.com/Azure/azure-iot-pcs-remote-monitoring-dotnet/issues/11
128 | # Public preview only: used to distinguish internal/external traffic
129 | proxy_set_header X-Source external;
130 | proxy_buffering off;
131 | client_max_body_size 0;
132 | proxy_read_timeout 3600s;
133 | proxy_redirect off;
134 | }
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/scripts/local/docker-compose.yml:
--------------------------------------------------------------------------------
1 | # This is the docker-compose script for local development.
2 | # For the latest version of the docker images see:
3 | # https://github.com/Azure/pcs-cli/blob/master/remotemonitoring/single-vm/docker-compose.dotnet.yml
4 | #
5 | # Usage:
6 | # - install Docker Compose, see https://docs.docker.com/compose/install
7 | # - open a console and `cd` into the folder that contains this file
8 | # - note how this file references many environment variables, either set
9 | # them in the .env file or edit this file adding the values here
10 | # - run `docker-compose up`
11 | # - open the browser at http://127.0.0.1:10443
12 | #
13 | # For more information see
14 | # https://github.com/Azure/azure-iot-pcs-remote-monitoring-dotnet
15 |
16 | version: "3"
17 |
18 | services:
19 |
20 | asamanager:
21 | image: azureiotpcs/asa-manager-dotnet:testing
22 | depends_on:
23 | - config
24 | - telemetry
25 | - iothubmanager
26 | ports:
27 | - "9024:9024"
28 | environment:
29 | - PCS_CONFIG_WEBSERVICE_URL=http://config:9005/v1
30 | - PCS_TELEMETRY_WEBSERVICE_URL=http://telemetry:9004/v1
31 | - PCS_IOTHUBMANAGER_WEBSERVICE_URL=http://iothubmanager:9002/v1
32 | - PCS_ASA_DATA_AZUREBLOB_ACCOUNT
33 | - PCS_ASA_DATA_AZUREBLOB_KEY
34 | - PCS_ASA_DATA_AZUREBLOB_ENDPOINT_SUFFIX
35 | - PCS_EVENTHUB_CONNSTRING
36 | - PCS_EVENTHUB_NAME
37 | - PCS_TELEMETRY_DOCUMENTDB_CONNSTRING
38 |
39 | reverseproxy:
40 | image: azureiotpcs/remote-monitoring-nginx:testing
41 | ports:
42 | - "10080:10080"
43 | depends_on:
44 | - webui
45 | - auth
46 | - iothubmanager
47 | - devicesimulation
48 | - telemetry
49 | - config
50 | volumes:
51 | # Required volume for app certs
52 | - ./config/nginx.conf:/app/config/nginx.conf:ro
53 |
54 | webui:
55 | image: azureiotpcs/pcs-remote-monitoring-webui:testing
56 | depends_on:
57 | - auth
58 | - iothubmanager
59 | - devicesimulation
60 | - telemetry
61 | - config
62 | # NOTE: Volumes disabled for local development, uncomment if enabling auth
63 | # volumes:
64 | # - ./webui-config.js:/app/build/webui-config.js:ro
65 |
66 | auth:
67 | image: azureiotpcs/pcs-auth-dotnet:testing
68 | environment:
69 | - PCS_AUTH_ISSUER
70 | - PCS_AUTH_AUDIENCE
71 | - PCS_AUTH_REQUIRED
72 | - PCS_CORS_WHITELIST
73 | - PCS_APPLICATION_SECRET
74 |
75 | iothubmanager:
76 | image: azureiotpcs/iothub-manager-java:testing
77 | depends_on:
78 | - storageadapter
79 | environment:
80 | - PCS_IOTHUB_CONNSTRING
81 | - PCS_STORAGEADAPTER_WEBSERVICE_URL=http://storageadapter:9022/v1
82 | - PCS_AUTH_ISSUER
83 | - PCS_AUTH_AUDIENCE
84 | - PCS_AUTH_REQUIRED
85 | - PCS_CORS_WHITELIST
86 | - PCS_APPLICATION_SECRET
87 |
88 | devicesimulation:
89 | image: azureiotpcs/device-simulation-dotnet:testing
90 | depends_on:
91 | - storageadapter
92 | environment:
93 | - PCS_IOTHUB_CONNSTRING
94 | - PCS_STORAGEADAPTER_WEBSERVICE_URL=http://storageadapter:9022/v1
95 | - PCS_AUTH_ISSUER
96 | - PCS_AUTH_AUDIENCE
97 | - PCS_AUTH_REQUIRED
98 | - PCS_CORS_WHITELIST
99 | - PCS_APPLICATION_SECRET
100 | # How one could mount custom device models
101 | # NOTE: Volumes disabled for local development
102 | # volumes:
103 | # - ./my-device-models:/app/data:ro
104 |
105 | telemetry:
106 | image: azureiotpcs/telemetry-dotnet:testing
107 | depends_on:
108 | - storageadapter
109 | environment:
110 | - PCS_TELEMETRY_DOCUMENTDB_CONNSTRING
111 | - PCS_STORAGEADAPTER_WEBSERVICE_URL=http://storageadapter:9022/v1
112 | - PCS_AUTH_ISSUER
113 | - PCS_AUTH_AUDIENCE
114 | - PCS_AUTH_REQUIRED
115 | - PCS_CORS_WHITELIST
116 | - PCS_APPLICATION_SECRET
117 |
118 | config:
119 | image: azureiotpcs/pcs-config-java:testing
120 | depends_on:
121 | - storageadapter
122 | - devicesimulation
123 | - telemetry
124 | environment:
125 | - PCS_STORAGEADAPTER_WEBSERVICE_URL=http://storageadapter:9022/v1
126 | - PCS_DEVICESIMULATION_WEBSERVICE_URL=http://devicesimulation:9003/v1
127 | - PCS_TELEMETRY_WEBSERVICE_URL=http://telemetry:9004/v1
128 | - PCS_AZUREMAPS_KEY
129 | - PCS_AUTH_ISSUER
130 | - PCS_AUTH_AUDIENCE
131 | - PCS_AUTH_REQUIRED
132 | - PCS_CORS_WHITELIST
133 | - PCS_APPLICATION_SECRET
134 |
135 | storageadapter:
136 | image: azureiotpcs/pcs-storage-adapter-java:testing
137 | environment:
138 | - PCS_STORAGEADAPTER_DOCUMENTDB_CONNSTRING
139 | - PCS_AUTH_ISSUER
140 | - PCS_AUTH_AUDIENCE
141 | - PCS_AUTH_REQUIRED
142 | - PCS_CORS_WHITELIST
143 | - PCS_APPLICATION_SECRET
144 |
145 | telemetryagent:
146 | image: azureiotpcs/telemetry-agent-java:testing
147 | depends_on:
148 | - telemetry
149 | - iothubmanager
150 | - config
151 | environment:
152 | - PCS_TELEMETRYAGENT_DOCUMENTDB_CONNSTRING
153 | - PCS_TELEMETRY_WEBSERVICE_URL=http://telemetry:9004/v1
154 | - PCS_CONFIG_WEBSERVICE_URL=http://config:9005/v1
155 | - PCS_IOTHUBMANAGER_WEBSERVICE_URL=http://iothubmanager:9002/v1
156 | - PCS_IOTHUBREACT_AZUREBLOB_ACCOUNT
157 | - PCS_IOTHUBREACT_AZUREBLOB_KEY
158 | - PCS_IOTHUBREACT_AZUREBLOB_ENDPOINT_SUFFIX
159 | - PCS_IOTHUBREACT_HUB_NAME
160 | - PCS_IOTHUBREACT_HUB_ENDPOINT
161 | - PCS_IOTHUBREACT_HUB_PARTITIONS
162 | - PCS_IOTHUBREACT_ACCESS_CONNSTRING
163 | - PCS_AUTH_ISSUER
164 | - PCS_AUTH_AUDIENCE
165 | - PCS_AUTH_REQUIRED
166 | - PCS_CORS_WHITELIST
167 | - PCS_APPLICATION_SECRET
168 |
--------------------------------------------------------------------------------
/scripts/update-gitsubmodules.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 |
5 | APP_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )/"
6 |
7 | cd $APP_HOME
8 |
9 | git checkout master
10 | git pull
11 |
12 | COL="\e[93m\e[1m"
13 | NOCOL="\e[0m"
14 |
15 | echo -e "${COL}### CLI${NOCOL}"
16 | cd $APP_HOME && git submodule update --init cli && cd cli && git checkout master && git pull
17 | echo -e "${COL}### Config${NOCOL}"
18 | cd $APP_HOME && git submodule update --init config && cd config && git checkout master && git pull
19 | echo -e "${COL}### Device Simulation${NOCOL}"
20 | cd $APP_HOME && git submodule update --init device-simulation && cd device-simulation && git checkout master && git pull
21 | echo -e "${COL}### IoT Hub Manager${NOCOL}"
22 | cd $APP_HOME && git submodule update --init iothub-manager && cd iothub-manager && git checkout master && git pull
23 | echo -e "${COL}### Storage Adapter${NOCOL}"
24 | cd $APP_HOME && git submodule update --init storage-adapter && cd storage-adapter && git checkout master && git pull
25 | echo -e "${COL}### Telemetry${NOCOL}"
26 | cd $APP_HOME && git submodule update --init telemetry && cd telemetry && git checkout master && git pull
27 | echo -e "${COL}### ASA Manager${NOCOL}"
28 | cd $APP_HOME && git submodule update --init asa-manager && cd asa-manager && git checkout master && git pull
29 | echo -e "${COL}### Web UI${NOCOL}"
30 | cd $APP_HOME && git submodule update --init webui && cd webui && git checkout master && git pull
31 |
32 | cd $APP_HOME
33 |
--------------------------------------------------------------------------------