Giter VIP home page Giter VIP logo

supplychain-azure-function-dataset-download's Introduction

supplychain-azure-function-dataset-download Function App

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.

The azure function allows the web-app to get the data associated to a given scenario, including parameters and datasets of types :

  • Azure Digital Twin
  • Cosmo Tech Twin Cache
  • Storage (lever files)

Deploy the generic Supply Chain Azure Function App

Pre-Requisites

  • Dedicated App registration created (see details below)

Dedicated app registration :

  1. Create a new app registration
  2. Add a API permission to the Cosmo Tech Platform API, choose the permission type Application (not Delegated) and select the permission Platform.Admin
  3. Create a client secret
  4. In the related Azure Digital Twins resources, assign the role Azure Digital Twin Data Reader to app registration

Deploy to Azure


Installation options

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 x.y.z

Configure CORS

Request Credentials

Check option Enable Access-Control-Allow-Credentials

Allowed Origins :


Secure the Azure Function

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

Add identity provider

  • 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

Configure audience

  • 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" )

Integrate in the Cosmo Tech Supply Chain web-app

Configure for the flowchart

in file "src/config/AppInstance.js"

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>',
};

Configure for the lever tables

in file "src/config/ScenarioParameters.js", for each lever table

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>' },
  }

Build and deploy the function app using a specific Supply Chain library version

Change the Supply Chain Library dependency

By default, the azure function app references the Cosmo-Tech Supply Chain generic PyPi package CosmoTech-SupplyChain from the requirements.txt file

In case, you need to use your own library version, you need to change this dependency by pointing to your own PyPi package or your specific git repository, like for exemple git+ssh://[email protected]/<your repo>/supplychain-python-library.git@main#egg=SupplyChain.

Note : in the azure function references in the requirements.txt file, you have to leave the dependency to the PyPi package CosmoTech-Acceleration-Library unchanged since this is one is generic.

Build the specific azure function

The generic azure comes with an GitHub action allowing to automate its build and the generation of the artifact Artifact.zip. This automatic build is facilitated by the fact that the generic PyPi package is public.

When you change the library dependency to a private repository, you need to put in place credentials management to use your own repository. You may find easier to simply build the azure function locally (using your git credentials)

pip install --target .python_packages/lib/site-packages/ -r requirements.txt
zip -r artifact.zip . -x ".git/*" ".github/*" ".gitignore"

Deploy the new specific Azure Function version

In order to deploy the new artifact, you have to make it accessible for deployment from the azure function app instance through an https URL.

Then to deploy the new artifact version, go to the azure function app settings in the Azure portal.
Change the WEBSITE_RUN_FROM_PACKAGE parameter with the new artifact URL.

Or execute the following command from the Azure CLI

az webapp config appsettings set --name <function app name> --resource-group <resource group name> --settings WEBSITE_RUN_FROM_PACKAGE=<URL>

Note : The function app automatically restarts after a configuration change.

supplychain-azure-function-dataset-download's People

Contributors

dsoitel avatar n1k1t4 avatar neomatamune avatar sjoubert avatar vcarluer avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.