- Azure Command Line Interface (CLI) >= 2.23.0 but <= 2.26.1
- A defect was introduced in Azure CLI version 2.27.0. As of October 2021, the latest release (2.29.0) continues to have this problem.
- Azure Functions Core Tools
- .NET Core 3.1 SDK
bashshell >= 4.1,/dev/urandom– included in macOS, Linux, Git for Windows, Azure Cloud Shellpsqlclient for PostgreSQL – included in Azure Cloud Shell- Node.js and
npmNode Package Manager for compiling assets during the build of ASP.NET Core web applications
To (re)create the Azure resources that piipan uses:
- Run
install-extensionsto install Azure CLI extensions required by theazcommands used by our IaC:
./iac/install-extensions.bash
- Connect to a trusted network. Currently, only the GSA network block is trusted.
- Configure the desired Azure cloud; either
AzureCloudorAzureUSGovernment:
az cloud set --name AzureCloud
- Sign in with the Azure CLI
logincommand. An account with at least the Contributor role on the subscription is required.
az login
- Run
create-resources, which deploys Azure Resource Manager (ARM) templates and runs associated scripts, specifying the name of the deployment environment. Once this step is completed, all the infrastructure components will be provisioned.
cd iac
./create-resources.bash tts/dev
-
Configuring user account authentication for piipan's Query Tool and Dashboard web apps requires additional actions. These actions can be deferred, but until completed, users will not be able to access these web apps.
- Securely obtain the OpenID Connect (OIDC) client secrets for the identity provider (IdP) configured in the
iac/envfile for your environment. - Run
store-oidc-secretsand follow the prompts to store the client secrets in the system's core key vault. - Run
configure-oidc-apps, to configure the Query Tool and Dashboard App Service instances with the client secrets.
- Securely obtain the OpenID Connect (OIDC) client secrets for the identity provider (IdP) configured in the
./store-oidc-secrets.bash tts/dev
./configure-oidc-apps.bash tts/dev
-
Create a subscription in the API Management service. At least for now, the API Management subscriptions are created manually and not by the IaC. For example, you’ll need to create
EA-DupPartandEA-BulkUploadbefore you can use thetest-apim-upload-api.bashandtest-apim-match-api.bashtest scripts.- Go to the Azure Portal
- Go to Resource Groups
- Look for
rg-match-devresource group - Go to
tts-apim-duppartapi-dev, an API Management service - Go to
Subscriptions, on the left menu - Click on
Add Subscription- Name:
EA-DupPart - Display Name:
EA-DupPart - Allow tracing:
uncheck - Scope:
API - API:
Duplicate participation API - Product:
blank - User:
blank - Click
Create
- Name:
- Click on
Add Subscription- Name:
EA-BulkUpload - Display Name:
EA-BulkUpload - Allow tracing:
uncheck - Scope:
API - API:
EA Bulk upload API - Product:
blank - User:
blank - Click
Create
- Name:
-
Now you have to assign the necessary “application role” for the API. Detailed documentation is found here, but if you just want to test your environment you can run the following steps.
Use assign-app-role to assign your user account the necessary application role:
#Template ./tools/assign-app-role.bash <azure-env> <function-app-name> <app-role-name> #Example ./tools/assign-app-role.bash tts/dev tts-func-metricsapi-dev Metrics.ReadUse authorize-cli to add the Azure CLI as an authorized client application for the Function's application registration:
#Template ./tools/authorize-cli.bash <azure-env> <function-app-name> #Example ./tools/authorize-cli.bash tts/dev tts-func-metricsapi-dev -
Time to test your infrastructure
#Test ETL ./etl/tools/test-apim-upload-api.bash tts/dev #Test Match ./match/tools/test-apim-match-api.bash tts/dev #Test Metrics ./metrics/tools/test-metricsapi.bash tts/dev
Configuration for each environment is in iac/env in a corresponding, source-able bash script.
| Name | Description |
|---|---|
tts/dev |
TTS-owned Azure commercial cloud, updated continuously within a sprint |
tts/test |
TTS-owned Azure commercial cloud, updated at the end of each sprint |
The following environment variables are pre-configured by the Infrastructure-as-Code for Functions or Apps that require them. Most often they are used to bind backing services to application code via connection strings.
| Name | Value | Used by |
|---|---|---|
DatabaseConnectionString |
ADO.NET-formatted database connection string. If Password has the value {password}; i.e., password in curly quotes, then it is a partial connection string indicating the use of managed identities. An access token must be retrieved at run-time (e.g., via AzureServiceTokenProvider) to build the full connection string. |
Piipan.Etl, Piipan.Match.Orchestrator, Piipan.Metrics.Func.Collect, Piipan.Metrics.Func.Api |
BlobStorageConnectionString |
Azure Storage Account connection string for accessing blobs. | Piipan.Etl |
OrchApiUri |
URI for the Orchestrator API endpoint. | Piipan.QueryTool |
States |
Comma-separated list of the lower-case two letter abbreviations for each participating state. | Piipan.Match.Orchestrator |
MetricsApiUri |
URI for the Metrics API endpoint. | Piipan.Dashboard |
KeyVaultName |
Name of key vault resource needed to acquire a secret | Piipan.Metrics.Func.Api, Piipan.Metrics.Func.Collect |
CloudName |
Name of the active Azure cloud environment, either AzureCloud or AzureUSGovernment |
Piipan.Etl, Piipan.Match.Orchestrator, Piipan.Metrics.Func.Api, Piipan.Metrics.Func.Collect |
The below resource tagging scheme is used for key Piipan components, using the SysType ("System Type") tag. This tag is used to ease enumeration of resource instances in IaC and to make a resource's system-level purpose more obvious in the Azure Portal. While a resource's name can make obvious its system type, often Azure naming restrictions and cloud-level uniqueness requirements can make those names inscrutable.
| Value | Description |
|---|---|
| PerStateEtl | one of N function apps for per-state bulk ETL process |
| PerStateStorage | one of N storage accounts for per-state bulk PII uploads |
| OrchestratorApi | the single Function App for the Orchestrator API |
| DashboardApp | the single Dashboard App Service |
| QueryApp | the single Query tool App Service |
| DupPartApi | the single API Management instance for the external-facing matching API |
In the Azure Portal, tags can be added to resource lists using the "Manage view" and/or "Edit columns" menu item that appears at the top left of the view. Specific tag values can also be filtered via "Add filter".
In the Azure CLI, az resource list can be used. Be sure to query for only the resources in the environment-specific resource group (e.g., -dev, -test, etc.):
az resource list --tag SysType=PerStateMatchApi --query "[? resourceGroup == 'rg-match-dev' ].name"
iac/states.csvcontains the comma-delimited records of participating states/territories. The first field is the two-letter postal abbreviation; the second field is the name of the state/territory.- For development, dummy state/territories are used (e.g., the state of
Echo Alpha, with an abbreviation ofEA). - If you forget to connect to a trusted network and
create-resourcesfails, connect to the network, then re-run the script. - If you have recently deleted all the Piipan resource groups and are re-creating the infrastructure from scratch, you will need to explicitly purge resource types that are initially soft-deleted. Be sure to perform these commands against the correct subscription/resource groups as they will cause irreversible data loss.
- Key Vaults
az keyvault list-deletedfor the names of soft-deleted vaults and identify the ones corresponding to your environment's resource groups.az keyvault purge --name <vault-name>for each relevant vault.- Now when you re-run
create-resources, you should not get theExist soft deleted vault with the same nameerror.
- API Management (APIM) instances
az rest --method GET --uri https://management.azure.com/subscriptions/<subscription-id>/providers/Microsoft.ApiManagement/deletedservices?api-version=2020-06-01-previewfor the names of soft-deleted APIM instances and identity the ones corresponding to your environment's resource groups. You'll need to usemanagement.usgovcloudapi.netin AzureUSGovernment.az rest --method DELETE --uri https://management.azure.com/subscriptions/<subscription-id>/providers/Microsoft.ApiManagement/locations/<region>/deletedservices/<apim-service-id>?api-version=2020-06-01-previewfor each relevant APIM instance.- Now when you re-run
create-resources, you should not get anDeploymentFailederror increate-apim.
- Key Vaults
- Some Azure CLI provisioning commands will return before all of their behind-the-scenes operations complete in the Azure environment. Very occasionally, subsequent provisioning commands in
create-resourceswill fail as it won't be able to locate services it expects to be present; e.g.,Can't find app with namewhen publishing a Function to a Function App. As a workaround, re-run the script. - .NET 5 with Azure Functions v3 is not (yet) supported by Microsoft.
iac/.azurecontains local Azure CLI configuration that is used bycreate-resources- In order for IaC to automatically configure the OIDC client secrets for the Dashboard and Query Tool applications, the secrets need to be present in a key vault with a particular naming format. See
configure-oidc.bashfor details.