page_type | languages | products | urlFragment | name | description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sample |
|
|
functions-javascript-sap-cloud-sdk-quickstart |
SAP Cloud SDK on Azure Functions Quickstart |
Quick-start project showcasing SAP Cloud SDK for JavaScript for SAP OData running on Azure Functions. |
This repos serves as quick-start project showcasing SAP Cloud SDK for JavaScript OData consumption running on Azure Functions. Its primary purpose is to set you up for success for your SAP extension project on Azure and reduce the lead time to your first successful deployment as much as possible with developer friendly commands.
It uses the Business Partner OData v2 API for SAP S/4HANA as an example.
The project is setup as per the best practices advocated by the Azure Developer CLI and referenced as official awesome azd template.
Looking for Azure App Service instead of Functions?🤔 Here you go.
Warning
Verify latest SAP's open-source license for the Cloud SDK for your reference.
Tip
- In case you need to translate between OData versions and metadata specification use our converter here.
- Looking for SAP Cloud Application Programming model instead of plain SAP Cloud SDK? See this sister project.
- In case you prefer an implementation without 3rd party library dependencies, have a look at this sister project.
- Looking for SAP Cloud SDK for Java? See this SAP repos.
Implementations using the approach described by this repos expand the feature scope of SAP's Cloud SDK for JavaScript to Azure PaaS apps.
Important
When deployed on Azure Functions instead of SAP Business Technology Platform, Cloud Foundry specific features like the destination service or XSUAA are not available.
- One code base to run on both Azure Functions and SAP Business Technology Platform
- Built in resiliency and caching patterns
- Native Azure authentication and token handling with Azure AD without any coding effort
- Configurable Azure API Management integration for SAP APIs including policy enforcement for use cases like request throttling, SAP token caching, etc.
- Native Azure virtual network integration next to the SAP workload
- Enabled for SAP Private Link and Azure Private Link / Private Endpoint (depending on wether you use the SAP Business Technology Platform or Azure only)
- OData v2 and v4 + entity and client generator managed by SAP
- OpenAPI + client generator managed by SAP
Example uses the NEST framework module azure-func-http compatible with Azure Functions runtime v3.
Follow the SAP Cloud SDK documentation for JavaScript for your project setup.
Use the devcontainer (with GitHub Codespaces for instance) or install the Azure Developer CLI in your environment.
Use any OData enabled SAP system:
- SAP's ABAP Platform Trial image,
- SAP's mock server (used in screenshots below),
- SAP API Business Hub S/4HANA Cloud sandbox with APIKey (
⚠️ read-only) - SAP's public demo system ES5 (
⚠️ Business Partner API not activated!), - S/4HANA Fully-Activated Appliance from SAP Cloud Appliance Library or
- your own available in-house SAP system.
Important
Be aware that SAP's mock server is anticipating the S4 Cloud version of the Business Partner API. So, you might need to adapt the mock server to your needs. During our testing at the time of release there were no discrepancies discovered. You may expose the mock server running locally for testing with the cloud services to the internet using ngrok or similar tools.
to hit the ground running with our tailored image and avoid installing anything on your local machine and continue with step 6.
Familiarize yourself with the SAP Cloud SDK for JavaScript developer tutorial
-
Run
azd auth login
. -
Run the following command to package a deployable copy of your application, provision the template's infrastructure to Azure and also deploy the application code to those newly provisioned resources.
azd up
This command will prompt you for the following information:
Azure Location
: The Azure location where your resources will be deployed.Azure Subscription
: The Azure Subscription where your resources will be deployed.
Note
This may take a while to complete as it executes three commands: azd package
(packages a deployable copy of your application), azd provision
(provisions Azure resources), and azd deploy
(deploys application code). You will see a progress indicator as it packages, provisions and deploys your application.
- Select suitable VS Code workspace. We suggest bicep as it is the default for Azure Developer CLI.
cd functions-javascript-sap-cloud-sdk-quickstart/src/api
npm install
cp ../../templates/.env ./.env
and maintain your OData url including credentialsnpm run start:azure
- Browse to http://localhost:8080/api/ for your "hello world"
- Maintain your SAP OData url with credentials in .env file (put in project root
functions-javascript-sap-cloud-sdk-quickstart/src/api
) and restart the app if necessary - Browse to http://localhost:8080/api/business-partner for your first OData call and pick one of the business partners (examples below use ids from SAP mock server)
Note
SAP's examples for the business partner API for SAP S/4HANA Cloud mentioned in the tutorial differ to the SAP S/4HANA on-premises flavor. Add AddressUsage, otherwise you will see "Internal error when calling operation module BUA_CHECK_ADDRESS_VALIDITY_ALL; a check table is missing". Check SAP KBA's for more details.
- Get that business partner by id: http://localhost:8080/api/business-partner/1003764
- Update the address with a house number: http://localhost:8080/api/business-partner/1003764/address/28238.
Note
For your convenience we provide a collection of REST calls in the repos. Execute them with the VS Code REST client.
- Delete the address: http://localhost:8080/api/business-partner/1003764/address/28238
- Add an address to your chosen business partner: http://localhost:8080/api/business-partner/1003764/address
Congratulations 🥳, you have successfully consumed SAP OData with the SAP Cloud SDK for JavaScript running on Azure Functions!
There are multiple ways to deploy this project to Azure. We provide two options in this repository:
- Via template deployment and VS Code extension. This approach allows an quick deployment to Azure but does not necessarily reflect the best practices. You find more information on this option here.
- Via Azure Developer CLI using
azd up
. This approach enables a quick and easy deployment and already contains best practices. It serves as a perfect starting point for a production grade setup. You find more information on this option here.
This repos build on functions is not configured to be deployed to SAP Business Technology Platform as is. We provide the necessary configurations for the deployment to SAP BTP leveraging the open source project btp setup automator for Azure App Service here.
You can do a lot more once the app is deployed. Curious? We go you covered with some more information on out-of-the-box authentication with Microsoft Entra ID, insights into networking, OpenUI5 for frontend design, and DevOps here.
Sometimes things do not work as expected. Here are some resources that support you in finding and fixing the issue:
- Access SAP Gateway logs in /IWFND/ERROR_LOG
- Azure Functions diagnostics
- Use Kudu SSH console from VNet integrated Functions to check connectivity to SAP Gateway with
curl https://<your domain>:<your https port>/sap/opu/odata/sap/API_BUSINESS_PARTNER -u "<user>:<password>"
- Azure API Management Request tracing
- Azure API Management Gateway logs
We collected additional resources and related efforts and projects here.
This project welcomes contributions and suggestions. Please use GitHub Issues to report errors or request new features. For conceptual conversations, please use GitHub Discussions
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.