Commit a2d1127c authored by Kishore Battula's avatar Kishore Battula
Browse files

Merge branch 'azure/updatingReadme' into 'master'

Updating Readme for register-azure

See merge request !53
parents ff147832 01286e66
Pipeline #19105 passed with stages
in 28 minutes and 5 seconds
Copyright © Microsoft Corporation
## os-register-azure
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
os-register-azure is a [Spring Boot](https://spring.io/projects/spring-boot) service that hosts CRUD APIs that allows consumers to register a push endpoint that can be triggered when data change events happen within the OSDU R2 ecosystem.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
# os-register-azure
## Running Locally
os-register-azure is a [Spring Boot](https://spring.io/projects/spring-boot) service that hosts CRUD APIs that allows consumers to register a push endpoint that can be triggered when data change events happen within the OSDU R2 ecosystem.
### Requirements
## Running locally
In order to run this service locally, you will need the following:
### Requirements
* Java 8
* [Maven 3.6.0+](https://maven.apache.org/download.cgi)
- [Maven 3.6.0+](https://maven.apache.org/download.cgi)
- [AdoptOpenJDK8](https://adoptopenjdk.net/)
### General Tips
......@@ -34,70 +24,66 @@ This project uses [Lombok](https://projectlombok.org/) for code generation. You
- [Intellij configuration](https://projectlombok.org/setup/intellij)
- [VSCode configuration](https://projectlombok.org/setup/vscode)
### Service Dependencies
- [Entitlements-azure](https://community.opengroup.org/osdu/platform/security-and-compliance/entitlements-azure)
- [Notification](https://community.opengroup.org/osdu/platform/system/notification)
### Configure Maven
### Entitlements
Check that maven is installed:
```bash
$ mvn --version
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 1.8.0_212, vendor: AdoptOpenJDK, runtime: /usr/lib/jvm/jdk8u212-b04/jre
...
```
You will need to configure access to the remote maven repository that holds the OSDU dependencies. This file should live within `~/.m2/settings.xml`:
```bash
$ cat ~/.m2/settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>os-core</id>
<username>slb-des-ext-collaboration</username>
<!-- Treat this auth token like a password. Do not share it with anyone, including Microsoft support. -->
<password>${VSTS_FEED_TOKEN}</password>
</server>
</servers>
</settings>
```
| name | description
| --- | --- |
| `users.datalake.admin` | Entitles users to access all the API's in register |
### Environment Variables
### Understanding Environment Variables
In order to run the service locally, you will need to have the following environment variables defined.
**System Environment required to run service**
Refer to [application.properties](./src/main/resources/application.properties)
Definitions for some variables used
**Required to run service**
| name | value | description | sensitive? | source |
| --- | --- | --- | --- | --- |
| `LOG_PREFIX` | `storage` | Logging prefix | no | - |
| `server.servlet.contextPath` | `/api/storage/v2/` | Servlet context path | no | - |
| `AUTHORIZE_API` | ex `https://foo-entitlements.azurewebsites.net` | Entitlements API endpoint | no | output of infrastructure deployment |
| `AUTHORIZE_API_KEY` | `********` | The API key clients will need to use when calling the entitlements | yes | -- |
| `azure.application-insights.instrumentation-key` | `********` | API Key for App Insights | yes | output of infrastructure deployment |
| `azure.activedirectory.client-id` | `********` | AAD client application ID | yes | output of infrastructure deployment |
| `azure.activedirectory.AppIdUri` | `api://${azure.activedirectory.client-id}` | URI for AAD Application | no | -- |
| `azure.activedirectory.session-stateless` | `true` | Flag run in stateless mode (needed by AAD dependency) | no | -- |
| `cosmosdb_account` | ex `devintosdur2cosmosacct` | Cosmos account name | no | output of infrastructure deployment |
| `cosmosdb_key` | `********` | Key for CosmosDB | yes | output of infrastructure deployments |
| `cosmosdb_database` | ex `dev-osdu-r2-db` | Cosmos database for storage documents | no | output of infrastructure deployment |
| `azure.storage.account-name` | ex `foo-storage-account` | Storage account for storing documents | no | output of infrastructure deployment |
| `azure.storage.enable-https` | `true` | Used by spring boot starter library | no | - |
| `servicebus_topic_name` | `recordstopic` | Topic for async messaging | no | output of infrastructure deployment |
| `servicebus_namespace_name` | ex `foo-sb-namespace` | Namespace for async messaging | no | output of infrastructure deployment |
| `KEYVAULT_URI` | ex `https://foo-keyvault.vault.azure.net/` | URI of KeyVault that holds application secrets | no | output of infrastructure deployment |
| `LOG_PREFIX` | `register` | Logging prefix | no | - |
| `server.servlet.contextPath` | `/api/register/v1/` | Servlet context path | no | - |
| `AZURE_CLIENT_ID` | `********` | Identity to run the service locally. This enables access to Azure resources. You only need this if running locally | yes | keyvault secret: `$KEYVAULT_URI/secrets/app-dev-sp-username` |
| `AZURE_TENANT_ID` | `********` | AD tenant to authenticate users from | yes | keyvault secret: `$KEYVAULT_URI/secrets/app-dev-sp-tenant-id` |
| `AZURE_TENANT_ID` | `********` | AD tenant to authenticate users from | yes | -- |
| `AZURE_CLIENT_SECRET` | `********` | Secret for `$AZURE_CLIENT_ID` | yes | keyvault secret: `$KEYVAULT_URI/secrets/app-dev-sp-password` |
| `KEY_IDENTIFIER` | `******` | Key Identifier for key used for encryption/decryption | yes | - |
| `AZURE_RESOURCE_GROUP_NAME` | `********` | Resource group name for event grid system topic | no | -- |
| `AZURE_SUBSCRIPTION_ID` | `******` | Azure tenant subscription id| no | -- |
| `KEYVAULT_URL` | ex `https://foo-keyvault.vault.azure.net/` | URI of KeyVault that holds application secrets | no | output of infrastructure deployment |
| `appinsights_key` | `********` | API Key for App Insights | yes | output of infrastructure deployment |
| `cosmosdb_database` | ex `foo-db` | The name of the CosmosDB database | no | output of infrastructure deployment |
| `spring.application.name` | `register-azure` | Name of application. Needed by App Insights | no | -- |
| `ENTITLEMENTS_API` | `https://entitlements.azurewebsites.net/entitlements/v1` | Entitlements API endpoint | no | -- |
| `server_port` | ex `8082` | Port the service will run on | no | -- |
| `RECORDS_CHANGE_PUBSUB_ENDPOINT` | ex `https://notification.azurewebsites.net/api/notification/v1/push-handler/records-changed` | This will be the notification service endpoint where record changed events will be pushed | no | -- |
| `SUBSCRIBER_SECRET` | ex `********` | This secret is required for test API, it is required in SubscriberTestListenerApi endpoints to verify HMAC signature| no | -- |
| `ACCEPT_HTTP` | ex `true/false` | to Enable/disable http requests | no | -- |
**Required to run integration tests**
| name | value | description | sensitive? | source |
| --- | --- | --- | --- | --- |
| `REGISTER_BASE_URL` | ex `http://localhost:8080/` | The host where the service is running | no | -- |
| `INTEGRATION_TESTER` | `********` | System identity to assume for API calls. Note: this user must have entitlements configured already | no | -- |
| `TESTER_SERVICEPRINCIPAL_SECRET` | `********` | Secret for `$INTEGRATION_TESTER` | yes | -- |
| `AZURE_AD_TENANT_ID` | `********` | AD tenant to authenticate users from | yes | -- |
| `AZURE_AD_APP_RESOURCE_ID` | `********` | AAD client application ID | yes | output of infrastructure deployment |
| `NO_DATA_ACCESS_TESTER` | `********` | Service principal ID of a service principal without entitlements | yes | `aad-no-data-access-tester-client-id` secret from keyvault |
| `NO_DATA_ACCESS_TESTER_SERVICEPRINCIPAL_SECRET` | `********` | Secret for `$NO_DATA_ACCESS_TESTER` | yes | `aad-no-data-access-tester-secret` secret from keyvault |
| `AZURE_STORAGE_ACCOUNT` | ex `foo-storage-account` | Storage account for storing documents | no | output of infrastructure deployment |
| `ENVIRONMENT` | ex local/dev | environment type | no | - |
| `SUBSCRIBER_SECRET` | ex '****' | e: This secret is required for test API, it is required in SubscriberTestListenerApi endpoints to verify HMAC signature | no | - |
| `TEST_TOPIC_NAME` | ex `records-topic` | the event grid topic name | no | - |
| `SUBSCRIPTION_ID` | ex `` | Base64 encoded string formed by concatenating pushEndpoint and topic name [Reference](https://community.opengroup.org/osdu/platform/system/register/-/blob/master/register-core/src/main/java/org/opengroup/osdu/register/subscriber/services/CreateSubscription.java#L54) | no | - |
### Configure Maven
Check that maven is installed:
```bash
$ mvn --version
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 1.8.0_212, vendor: AdoptOpenJDK, runtime: /usr/lib/jvm/jdk8u212-b04/jre
...
```
### Build and run the application
After configuring your environment as specified above, you can follow these steps to build and run the application. These steps should be invoked from the *repository root*.
......@@ -117,5 +103,28 @@ $ mvn spring-boot:run -Dspring-boot.run.profiles=local
$ cd provider/register-azure/ && java -jar target\register-azure-1.0.0-spring-boot.jar
```
### Debugging
Jet Brains - the authors of Intellij IDEA, have written an [excellent guide](https://www.jetbrains.com/help/idea/debugging-your-first-java-application.html) on how to debug java programs.
### Test the application
After the service has started it should be accessible via a web browser by visiting [http://localhost:8080/api/register/v1/swagger-ui.html](http://localhost:8080/api/register/v1/swagger-ui.html). If the request does not fail, you can then run the integration tests.
\ No newline at end of file
After the service has started it should be accessible via a web browser by visiting [http://localhost:8080/api/register/v1/swagger-ui.html](http://localhost:8080/api/register/v1/swagger-ui.html). If the request does not fail, you can then run the integration tests.
### Commands to run tests
* Integration tests are refactored into two pieces: Core and Provider. Core contains business logic for tests and is a dependency for executing the tests from provider module. To build the core module, simply navigate to `register-test-core` directory and run `mvn clean install`. This will build the core module
* Next, to execute the integration tests, navigate to the provider module and execute `mvn test`. Make sure the above environment variables are already set before running maven command
## License
Copyright © Microsoft Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment