This folder contains the Python code for the Activity Function. The Activity Function performs individual steps of the transaction, such as processing a part of the business logic and writing to Cosmos DB.
activity_function.py: Python code for the Activity Function.requirements.txt: Lists the dependencies required by the Activity Function.deploy-activity.yml: GitHub Action workflow to automate the deployment of the Activity Function.
- Azure Subscription: You need an active Azure account.
- Azure Function App: Ensure the Azure Function App is created (using the Bicep template in the
/infrastructurefolder). - GitHub Secrets Configuration:
AZURE_CREDENTIALS: Azure service principal credentials in JSON format.AZURE_FUNCTIONAPP_PUBLISH_PROFILE: Publish profile for the Azure Function App.ServiceBusConnection: Connection string for the Azure Service Bus namespace.CosmosDBConnectionString: Connection string for the Azure Cosmos DB account.
-
Add Required Secrets to GitHub:
- Go to your repository's Settings > Secrets and variables > Actions > New repository secret.
- Add the following secrets:
AZURE_CREDENTIALS: Your Azure service principal credentials.AZURE_FUNCTIONAPP_PUBLISH_PROFILE: The publish profile for your Azure Function App.ServiceBusConnection: The connection string for your Azure Service Bus namespace.CosmosDBConnectionString: The connection string for your Azure Cosmos DB account.
-
Run the GitHub Action:
- Push your changes to the
mainbranch or manually trigger the Deploy Activity Function workflow from the Actions tab.
- Push your changes to the
-
Monitor the Deployment:
- Go to the Actions tab in your GitHub repository.
- Select the Deploy Activity Function workflow to monitor the deployment progress.
-
Listen for Messages:
- The Activity Function is triggered when it receives a message from the Service Bus Topic (
sagaServiceBusTopic). - This message contains order details, such as
orderId,customerName, anditems.
- The Activity Function is triggered when it receives a message from the Service Bus Topic (
-
Process the Transaction:
- The function writes the order details to Azure Cosmos DB.
- If successful, the data is stored in the Cosmos DB container; otherwise, it logs an error.
This project is licensed under the MIT License - see the LICENSE file for details.