The supplychain-azure-function-dataset-download is a specialization for the Cosmo Tech Supply Chain solution of the the generic azure function app azure-function-scenario-download
This Supply Chain specific version is based on the Cosmotech Azure function Scenario Download
This azure function app aims to be integrated in the Cosmo Tech Supply Chain Web-app : azure-supplychain-webapp for Cosmo Tech internal use or azure-supplychain-webapp-shared for external use
Running the following commands in a terminal will create a file Artifact.zip
which can then be used for deployment
pip install --target .python_packages/lib/site-packages/ -r requirements.txt
zip -r artifact.zip . -x ".git/*" ".github/*" ".gitignore"
- Dedicated App registration created (see details below)
- Create a new app registration
- Add a API permission to the Cosmo Tech Platform API, choose the permission type Application (not Delegated) and select the permission Organization.user
- Create a client secret
- In the related Azure Digital Twins resources, assign the role Azure Digital Twin Data Reader to app registration
Parameter | Note |
---|---|
Subscription | Choose same as the related platform and webapp |
Resource group | Choose same as the related platform and webapp |
Region | Choose same as related platform and webapp |
Site Name | Choose a name for the function app or leave the default value for auto-generated name |
Storage Account Name | Choose a name for the storage account required for the function app or leave the default value for auto-generated name |
Location | Location for the resources to be created (Function App, App Service plan and Storage Account) |
Csm Api Host | Cosmo Tech Platform API host |
Csm Api Scope | Scope for accessing the Cosmo Tech Platform API (must end with /.default) |
Az Cli ID | Client ID of the dedicated app registration (see pre-requisites) |
Az Cli Secret | Client Secret create of the dedicated app registration (see pre-requisites) |
Package Address | URL of the Azure function package to be deployed - IMPORTANT : pick the URL from the latest release, ex release 2.1.10 |
Check option Enable Access-Control-Allow-Credentials
- Add the URL of the Cosmo Tech Supply Chain Web-App
- For dev usage (optional) add http://localhost:3000
The azure function includes a first level of securizartion with the host key.
This keys being included in the web application, we need a second layer of securization by limiting the azure function calls to the users being authorized to the Cosmo Tech API
- Go to Authentication
- Add identity provider
- Select "Microsoft"
- In "App registration type", select "Pick an existing app registration in this directory"
- Name or app ID : enter the web application name.
Note : You may need to enter the app registration ID created for the webapp instead of its name. And in this case, you will have to create a secret for the app registration of the web app and provide it here.
- Restrict access : "Require authentication"
- Unauthenticated requests : HTTP 401
- Token store : leave checked
- In the created identity provider, click on "Edit"
- Allowed token audiences : Enter the appplication ID URL of the platform app registration (of type "https://cosmo platform url" or "api://platform app registrion application id uri" )
export const AZURE_FUNCTION_FLOWCHART_URL =
'https://<azure function deployment url>/api/ScenarioDownload';
export const AZURE_FUNCTION_FLOWCHART_HEADERS = {
'x-functions-key': '<default host keys>',
};
Example with the demand plan table
demand_plan: {
connectorId: 'c-ll43p5nll5xqx',
defaultFileTypeFilter: '.csv',
subType: 'AZURETABLE',
azureFunction: 'https://<azure function deployment url>/api/DemandsPlan',
azureFunctionHeaders: { 'x-functions-key': '<default host keys>' },
}