Merge pull request #6 from zobanyai/main
Modified authentication, deployment and get the contact id
This commit is contained in:
Коммит
5744c47b74
|
@ -11,9 +11,9 @@ The Starter kit aims is to simplify the development process and allow Microsoft
|
|||
1. [Node.js](https://nodejs.dev) version from 14.x or 16.x (recommended).
|
||||
2. [Yarn](https://yarnpkg.com) for workspace package management.
|
||||
|
||||
### If you want to experiment with our Starter kit in a demo web app using Azure Web Services
|
||||
### If you want to experiment with our Starter kit in a demo web app using Azure Web Apps
|
||||
|
||||
1. Active Azure Web Services subscriptions
|
||||
1. Active Azure subscription
|
||||
2. VS Studio Code and [Azure Function Extension Pack](https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-node-azure-pack)
|
||||
3. [Azure Functions Core Tools 4.x](https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local#install-the-azure-functions-core-tools)
|
||||
4. [Experimenting with Azure Static Web Apps](https://azure.github.io/static-web-apps-cli/)
|
||||
|
|
|
@ -22,3 +22,6 @@ dist-ssr
|
|||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
*-api.zip
|
||||
*-app.zip
|
||||
.env
|
|
@ -1,15 +1,15 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
const axios = require('axios')
|
||||
|
||||
const endPoint = `${process.env.ENVIRONMENT_URL}/api/data/${process.env.ENVIRONMENT_VERSION}`
|
||||
|
||||
module.exports = async function (context, req) {
|
||||
|
||||
const url = `${endPoint}/${req.body.fsiCallbackName}`;
|
||||
const data = req.body.payload?.body ? { ...req.body.payload?.body } : undefined
|
||||
|
||||
if (data && req.body.payload?.Contact) {
|
||||
|
||||
if (data && req.body.payload?.Contact && req.body.fsiCallbackName !== 'msfsi_GetAvailableMeetingTimeSlots') {
|
||||
data.Contact = req.body.payload?.Contact
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ module.exports = async function (context, req) {
|
|||
data,
|
||||
})
|
||||
|
||||
|
||||
context.res = {
|
||||
status: response.status,
|
||||
body: response.data
|
||||
|
|
|
@ -0,0 +1,157 @@
|
|||
{
|
||||
"name": "sample-azure-function",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "sample-azure-function",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"axios": "^0.27.2"
|
||||
},
|
||||
"devDependencies": {}
|
||||
},
|
||||
"node_modules/asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "0.27.2",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz",
|
||||
"integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.14.9",
|
||||
"form-data": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||
"dependencies": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/follow-redirects": {
|
||||
"version": "1.15.2",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
|
||||
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://github.com/sponsors/RubenVerborgh"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"debug": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/form-data": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
|
||||
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
"mime-types": "^2.1.12"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-types": {
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"dependencies": {
|
||||
"mime-db": "1.52.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
||||
},
|
||||
"axios": {
|
||||
"version": "0.27.2",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz",
|
||||
"integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==",
|
||||
"requires": {
|
||||
"follow-redirects": "^1.14.9",
|
||||
"form-data": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||
"requires": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
}
|
||||
},
|
||||
"delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ=="
|
||||
},
|
||||
"follow-redirects": {
|
||||
"version": "1.15.2",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
|
||||
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA=="
|
||||
},
|
||||
"form-data": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
|
||||
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
||||
"requires": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
"mime-types": "^2.1.12"
|
||||
}
|
||||
},
|
||||
"mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="
|
||||
},
|
||||
"mime-types": {
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"requires": {
|
||||
"mime-db": "1.52.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,8 +13,12 @@ export const delegator = async (request: IRequestPayload) => {
|
|||
}
|
||||
|
||||
if (data.payload?.body) {
|
||||
//The current logged in user contact id is required for the request with the body payload
|
||||
(data as any).payload.Contact = (window as any).currentUser?.id
|
||||
|
||||
|
||||
//SAMPLE CODE: Get the contact id from a query parameter http://[YOUR URL]/?id=[GUID]
|
||||
const queryParams = new URLSearchParams(window.location.search);
|
||||
// This will get the 'id' parameter from the url. This can be used if you use the sample web app in an iFrame
|
||||
(data as any).payload.Contact = queryParams.get('id')
|
||||
}
|
||||
|
||||
const result = await sendRequest(endpoint, {
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
# Install Azure CLI: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows?tabs=azure-cli
|
||||
#az --version >= 2.36+
|
||||
|
||||
# Install app dependencies
|
||||
npm install react
|
||||
|
||||
# Run on \Cloud-for-Financial-Services---samples\intelligent-appointment\appointment-starter-kit
|
||||
cd..
|
||||
cd appointment-starter-kit
|
||||
yarn build
|
||||
|
||||
#Run on: \Cloud-for-Financial-Services---samples\intelligent-appointment\demo-web-app
|
||||
|
||||
# Build SWA Project
|
||||
cd..
|
||||
cd demo-web-app
|
||||
swa build --app-location . --output-location dist --api-location api --app-build-command "yarn build" --api-build-command "npm run build --if-present"
|
||||
|
||||
# Prompting user for the configuration parameters
|
||||
$tenantId = Read-Host -Prompt 'Enter your Azure Active Directory tenant ID'
|
||||
$subscriptionId = Read-Host -Prompt 'Enter your Azure subscription ID'
|
||||
$resourceGroup = Read-Host -Prompt 'Enter your resource group name'
|
||||
$clientId = Read-Host -Prompt 'Enter your App client id' # This is the application client id from the app registration
|
||||
$clientSecret = Read-Host -Prompt 'Enter your client secret value' # This is the application client secret from the app registration
|
||||
$env_url = Read-Host -Prompt 'Enter your environment URL'
|
||||
$region = Read-Host -Prompt 'Enter your prefered region location (e.g centralus, eastus2, eastasia, westeurope. westus2)'
|
||||
$appName = Read-Host -Prompt 'Enter your Static WebApp application name'
|
||||
$env_version = Read-Host -Prompt 'Enter your environment version'
|
||||
|
||||
# Azure Login
|
||||
az login
|
||||
|
||||
# Change the active subscription using the subscription ID
|
||||
az account set --subscription $subscriptionId
|
||||
|
||||
# Create Azure Static Web App (SWA)
|
||||
# May need to set new app --name and --resource-group
|
||||
az staticwebapp create --name $appName --resource-group $resourceGroup --api-location api --output-location dist --location $region
|
||||
|
||||
# Azure SWA Login
|
||||
# May need to set new --subscription-id and --resource-group and --tenant-id
|
||||
swa login --subscription-id $subscriptionId --resource-group $resourceGroup --tenant-id $tenantId --clear-credentials
|
||||
|
||||
# Get Deployment Token
|
||||
# May need to set new app --name
|
||||
$deploymentKey = az staticwebapp secrets list --name $appName --query "properties.apiKey"
|
||||
|
||||
# Deploy Azure Static Web App
|
||||
# May need to set new app --name and --resource-group
|
||||
swa deploy --deployment-token=$deploymentKey ./dist --api-location ./api --env production --app-name $appName --resource-group $resourceGroup
|
||||
|
||||
# Set Environment Variables
|
||||
# May need to set new app --name and ENVIRONMENT_URL
|
||||
# Set CLIENT_ID, CLIENT_SECRET, TENANT with the values from the previoulsly created Azure AD App Registration and the Environment Version
|
||||
az staticwebapp appsettings set --name $appName --setting-names CLIENT_ID=$clientId CLIENT_SECRET=$clientSecret ENVIRONMENT_URL=$env_url TENANT=$tenantId ENVIRONMENT_VERSION=$env_version
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -10,5 +10,8 @@
|
|||
"devDependencies": {
|
||||
"vite-plugin-dts": "^1.3.0",
|
||||
"yarn": "1.22.19"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^17.0.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче