Skip to content

Commit 93ca129

Browse files
committed
Merge branch 'release/2024.1.3' into main
2 parents c9656c3 + e3e5cf5 commit 93ca129

22 files changed

Lines changed: 308 additions & 189 deletions

.env.sample

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ REACT_APP_ONEDS_TENANT_KEY=
1111
REACT_APP_API_ROOT=https://planetarycomputer-staging.microsoft.com
1212

1313
# Root URL for image function app endpoints
14-
REACT_APP_IMAGE_API_ROOT=
14+
REACT_APP_IMAGE_API_ROOT=https://planetarycomputer-staging.microsoft.com/api/f
1515

16-
# Subscription key for Azure Maps
17-
REACT_APP_AZMAPS_KEY=
16+
# Client Id for Azure Maps
17+
REACT_APP_AZMAPS_CLIENT_ID=8f49b6d6-5845-4e20-9015-9630df1ca8d2
1818

1919
# URL for JHub cloned repo launch (including 'git-pull')
2020
REACT_APP_HUB_URL=

.github/workflows/azure-static-web-apps-icy-meadow-0fc35e30f.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ on:
1111

1212
jobs:
1313
build_and_deploy_job:
14+
permissions:
15+
pull-requests: write
1416
environment: staging
1517
if:
1618
github.event_name == 'push' || (github.event_name == 'pull_request' &&
@@ -20,10 +22,9 @@ jobs:
2022
env:
2123
REACT_APP_API_ROOT: ${{ secrets.API_ROOT }}
2224
REACT_APP_IMAGE_API_ROOT: ${{ secrets.IMAGE_API_ROOT }}
25+
REACT_APP_AZMAPS_CLIENT_ID: ${{ secrets.AZMAPS_CLIENT_ID }}
2326
REACT_APP_ONEDS_TENANT_KEY: ${{ secrets.ONEDS_TENANT_KEY }}
24-
REACT_APP_AZMAPS_KEY: ${{ secrets.AZMAPS_KEY }}
2527
REACT_APP_HUB_URL: ${{ secrets.HUB_URL }}
26-
REACT_APP_AUTH_URL: ${{ secrets.AUTH_URL }}
2728
steps:
2829
- uses: actions/checkout@v3
2930
with:

.github/workflows/azure-static-web-apps-thankful-sand-0ed34c70f.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ on:
1111

1212
jobs:
1313
build_and_deploy_job:
14+
permissions:
15+
pull-requests: write
1416
environment: production
1517
if:
1618
github.event_name == 'push' || (github.event_name == 'pull_request' &&
@@ -20,9 +22,8 @@ jobs:
2022
env:
2123
REACT_APP_API_ROOT: ${{ secrets.API_ROOT }}
2224
REACT_APP_IMAGE_API_ROOT: ${{ secrets.IMAGE_API_ROOT }}
23-
REACT_APP_JSLL_APP_ID: ${{ secrets.JSLL_APP_ID }}
25+
REACT_APP_AZMAPS_CLIENT_ID: ${{ secrets.AZMAPS_CLIENT_ID }}
2426
REACT_APP_ONEDS_TENANT_KEY: ${{ secrets.ONEDS_TENANT_KEY }}
25-
REACT_APP_AZMAPS_KEY: ${{ secrets.AZMAPS_KEY }}
2627
REACT_APP_HUB_URL: ${{ secrets.HUB_URL }}
2728
steps:
2829
- uses: actions/checkout@v3

.github/workflows/azure-static-web-apps-wonderful-stone-06c70c70f.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ on:
1111

1212
jobs:
1313
build_and_deploy_job:
14+
permissions:
15+
pull-requests: write
1416
environment: test
1517
if:
1618
github.event_name == 'push' || (github.event_name == 'pull_request' &&
@@ -20,10 +22,9 @@ jobs:
2022
env:
2123
REACT_APP_API_ROOT: ${{ secrets.API_ROOT }}
2224
REACT_APP_IMAGE_API_ROOT: ${{ secrets.IMAGE_API_ROOT }}
25+
REACT_APP_AZMAPS_CLIENT_ID: ${{ secrets.AZMAPS_CLIENT_ID }}
2326
REACT_APP_ONEDS_TENANT_KEY: ${{ secrets.ONEDS_TENANT_KEY }}
24-
REACT_APP_AZMAPS_KEY: ${{ secrets.AZMAPS_KEY }}
2527
REACT_APP_HUB_URL: ${{ secrets.HUB_URL }}
26-
REACT_APP_AUTH_URL: ${{ secrets.AUTH_URL }}
2728
steps:
2829
- uses: actions/checkout@v3
2930
with:

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,29 @@ First, copy `.env.sample` file to `.env`, and ensure the configuration values ar
6868
|`REACT_APP_API_ROOT`| <https://planetarycomputer-staging.microsoft.com> | The root URL for the STAC API, either prod, staging or a local instance. If the URL ends in 'stac', this is a special case that is handled by replacing 'stac' with the target service, e.g. 'data' or 'sas'
6969
|`REACT_APP_TILER_ROOT`| Optional | The root URL for the data tiler API, if not hosted from the domain of the STAC API.
7070
|`REACT_APP_IMAGE_API_ROOT`| PC APIs pcfunc endpoint | The root URL for the image data API for animations.
71-
|`REACT_APP_AZMAPS_KEY`| Retrieve from Azure Portal | The key used to authenticate the Azure Maps inset map on a dataset detail page.
71+
|`REACT_APP_AZMAPS_CLIENT_ID`| Retrieve from Azure Portal | The Client ID used to authenticate against Azure Maps.
7272
|`REACT_APP_HUB_URL`| Optional. URL to root Hub instance | Used to enable a request to launch the Hub with a specific git hosted file.
7373
|`REACT_APP_ONEDS_TENANT_KEY`| Lookup at <https://1dswhitelisting.azurewebsites.net/> | Telemetry key (not needed for dev)
7474
|`REACT_APP_AUTH_URL`| Optional. URL to root pc-session-api instance | Used to enable login work.
7575

76-
Run `./scripts/server` to launch a development server.
76+
Run `./scripts/server --api` to launch a development server with a local Azure Functions host running.
77+
78+
#### Azure Maps
79+
80+
In the local development setups, the Azure Maps token is generated using the local developer identity. Be sure to
81+
`az login` and `az account set --subscription "Planetary Computer"` to ensure the correct token is generated. Your identity
82+
will also need the "Azure Maps Search and Render Data Reader" permission, which can be set with:
83+
84+
```sh
85+
USER_NAME=$(az account show --query user.name -o tsv)
86+
az role assignment create \
87+
--assignee "$USER_NAME" \
88+
--role "Azure Maps Search and Render Data Reader" \
89+
--scope "/subscriptions/9da7523a-cb61-4c3e-b1d4-afa5fc6d2da9/resourceGroups/pc-datacatalog-rg/providers/Microsoft.Maps/accounts/pc-datacatalog-azmaps" \
90+
--subscription "Planetary Computer"
91+
```
92+
93+
Note, you may need to assign this role via an identity that has JIT admin privileges enabled against the Planetary Computer subscription.
7794

7895
#### Developing against local STAC assets
7996

api/Dockerfile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
FROM mcr.microsoft.com/azure-functions/python:4-python3.9
1+
FROM mcr.microsoft.com/azure-cli:cbl-mariner2.0
22

33
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
44
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
55

6+
RUN tdnf install libicu unzip wget -y
7+
RUN wget https://github.com/Azure/azure-functions-core-tools/releases/download/4.0.5530/Azure.Functions.Cli.linux-x64.4.0.5530.zip
8+
RUN mkdir -p /usr/local/lib/Azure.Functions.Cli
9+
RUN unzip Azure.Functions.Cli.linux-x64.4.0.5530.zip -d /usr/local/lib/Azure.Functions.Cli
10+
RUN chmod +x /usr/local/lib/Azure.Functions.Cli/func
11+
12+
ENV PATH="/usr/local/lib/Azure.Functions.Cli:${PATH}"
13+
14+
RUN python3 -m ensurepip --upgrade
615
COPY requirements.txt /
7-
RUN pip install -r /requirements.txt
16+
RUN pip3 install -r /requirements.txt
817

918
COPY requirements-dev.txt /
10-
RUN pip install -r /requirements-dev.txt
19+
RUN pip3 install -r /requirements-dev.txt

api/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ To set appropriate configuration values for the Function app, copy the `local.se
1212

1313
The `local.settings.json` file has the following keys in the Values section:
1414

15-
|Key|KeyVault Key|Purpose|
16-
|---|---|---|
17-
|`NotificationHook`| | URL to send Teams notification on new Account Request
18-
|`AuthAdminUrl`| | URL to the PC ID admin page which contains the signup table. Used in the Teams notification message.
19-
|`SignupUrl`| | URL to POST new user content to on submission
20-
|`SignupToken` | `pc-id--request-auth-token` | Bearer token required to make the above POST request
15+
| Key | KeyVault Key | Purpose |
16+
|--------------------|-----------------------------|------------------------------------------------------------------------------------------------------|
17+
| `NotificationHook` | | URL to send Teams notification on new Account Request |
18+
| `AuthAdminUrl` | | URL to the PC ID admin page which contains the signup table. Used in the Teams notification message. |
19+
| `SignupUrl` | | URL to POST new user content to on submission |
20+
| `SignupToken` | `pc-id--request-auth-token` | Bearer token required to make the above POST request |
2121

2222
### Production
2323

api/map-token/__init__.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import json
2+
import logging
3+
from typing import TypedDict
4+
5+
import azure.functions as func
6+
7+
from azure.identity import DefaultAzureCredential
8+
from azure.core.exceptions import ClientAuthenticationError
9+
10+
logger = logging.getLogger("api.maps-token")
11+
# For performance, exclude checking options we know won't be used
12+
credential = DefaultAzureCredential(
13+
exclude_environment_credential=True,
14+
exclude_developer_cli_credential=True,
15+
exclude_powershell_credential=True,
16+
exclude_visual_studio_code_credential=True,
17+
)
18+
19+
20+
class TokenResponse(TypedDict):
21+
token: str
22+
expires_on: int
23+
24+
25+
def main(req: func.HttpRequest) -> func.HttpResponse:
26+
27+
logger.debug("Python HTTP trigger function processed a request.")
28+
try:
29+
logger.debug("Getting azure maps token")
30+
token = credential.get_token("https://atlas.microsoft.com/.default")
31+
logger.debug("Token acquired")
32+
33+
resp: TokenResponse = {"token": token.token, "expires_on": token.expires_on}
34+
35+
return func.HttpResponse(status_code=200, body=json.dumps(resp))
36+
except ClientAuthenticationError:
37+
logger.exception(f"Error getting azure maps token")
38+
return func.HttpResponse("Error getting token", status_code=500)

api/map-token/function.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"scriptFile": "__init__.py",
3+
"bindings": [
4+
{
5+
"authLevel": "function",
6+
"type": "httpTrigger",
7+
"direction": "in",
8+
"name": "req",
9+
"methods": [
10+
"get"
11+
]
12+
},
13+
{
14+
"type": "http",
15+
"direction": "out",
16+
"name": "$return"
17+
}
18+
]
19+
}

api/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
# Manually managing azure-functions-worker may cause unexpected issues
44

55
azure-functions==1.11.2
6+
azure-identity==1.15.0
67
requests==2.31.0

0 commit comments

Comments
 (0)