Thanks to visit codestin.com
Credit goes to github.com

Skip to content

malaker/Azure-PowerPlatform-Lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Azure & Power Platform Integration Lab

A comprehensive lab environment for testing Power Platform premium features with Azure integration using managed identities, VNet integration, and enterprise security patterns.

License: MIT Azure Terraform .NET Power Platform

🎯 Purpose

This repository provides a quick and automated way to provision Azure and Power Platform resources for:

  • βœ… Testing Power Platform premium features (Managed Environments, VNet Integration, Enterprise Policies)
  • βœ… Learning enterprise integration patterns between Power Platform and Azure
  • βœ… Demonstrating managed identity authentication (no secrets in code!)
  • βœ… Exploring secure networking (VNets, Private Endpoints, Firewalls, NAT Gateway)
  • βœ… Building production-like architectures with minimal cost (~$0-15/month default config)

πŸ—οΈ Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         Power Platform                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚ Dataverse Environment (Developer - FREE)                     β”‚   β”‚
β”‚  β”‚  β€’ Managed Environment Features                              β”‚   β”‚
β”‚  β”‚  β€’ VNet Integration (Enterprise Policy)                      β”‚   β”‚
β”‚  β”‚  β€’ Custom APIs (Dataverse Plugins with Managed Identity)     β”‚   β”‚
β”‚  β”‚  β€’ Federated Identity Credentials (workload identity)        β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚ Private Connectivity
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    β”‚              Azure                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚ VNet (West Europe + North Europe paired regions)             β”‚   β”‚
β”‚  β”‚  β€’ Subnet Delegation for Power Platform                      β”‚   β”‚
β”‚  β”‚  β€’ Private DNS Zones                                         β”‚   β”‚
β”‚  β”‚  β€’ Network Security Groups                                   β”‚   β”‚
β”‚  β”‚  β€’ NAT Gateway (optional - whitelistable IP)                 β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                              Optional              Optional         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚  Azure Functions β”‚  β”‚  Logic App Std   β”‚  β”‚  Data Factory   β”‚    β”‚
β”‚  β”‚  (.NET 8 Flex)   β”‚  β”‚  (Workflows)     β”‚  β”‚  (Managed VNet) β”‚    β”‚
β”‚  β”‚  β€’ VNet Integration  β€’ VNet Integrationβ”‚  β”‚  β€’ Dataverse    β”‚    β”‚
β”‚  β”‚  β€’ OAuth2 + OBO  β”‚  β”‚  β€’ Dataverse     β”‚  β”‚    Linked Svc   β”‚    β”‚
β”‚  β”‚  β€’ RBAC Auth     β”‚  β”‚    Connector     β”‚  β”‚  β€’ RBAC Auth    β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”‚          Optional                                                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚  API Management  β”‚  β”‚  Key Vault       β”‚  β”‚  Storage Accts  β”‚    β”‚
β”‚  β”‚  (BFF Pattern)   β”‚  β”‚  (RBAC-based)    β”‚  β”‚  (RBAC-based)   β”‚    β”‚
β”‚  β”‚  β€’ Internal VNet β”‚  β”‚  β€’ VNet Rules    β”‚  β”‚  β€’ VNet Rules   β”‚    β”‚
β”‚  β”‚  β€’ OAuth Validation β”‚  β€’ Secrets Mgmt  β”‚  β”‚  β€’ Private EP   β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Repository Structure

Azure-PowerPlatform-Lab/
β”œβ”€β”€ README.md                                      # This file
β”œβ”€β”€ LICENSE                                        # MIT License
β”œβ”€β”€ .gitignore                                     # Git ignore patterns
β”‚
β”œβ”€β”€ Infrastructure/                                # Terraform IaC
β”‚   └── terraform/
β”‚       β”œβ”€β”€ README.md                              # Detailed infrastructure docs
β”‚       β”œβ”€β”€ deploy.ps1                             # Deployment automation script
β”‚       β”œβ”€β”€ main.tf                                # Core orchestration
β”‚       β”œβ”€β”€ variables.tf                           # Variable declarations
β”‚       β”œβ”€β”€ locals.tf                              # Local values and naming
β”‚       β”œβ”€β”€ providers.tf                           # Provider configuration
β”‚       β”œβ”€β”€ versions.tf                            # Version constraints
β”‚       β”œβ”€β”€ outputs.tf                             # Output definitions
β”‚       β”‚
β”‚       β”œβ”€β”€ Resources/                             # Resource-specific configs
β”‚       β”‚   β”œβ”€β”€ api-management.tf                  # API Management
β”‚       β”‚   β”œβ”€β”€ data-factory.tf                    # Data Factory
β”‚       β”‚   β”œβ”€β”€ function-app.tf                    # Azure Functions
β”‚       β”‚   β”œβ”€β”€ logic-apps.tf                      # Logic App Standard
β”‚       β”‚   β”œβ”€β”€ network.tf                         # VNet, subnets, DNS
β”‚       β”‚   └── power-platform.tf                  # Power Platform envs
β”‚       β”‚
β”‚       β”œβ”€β”€ modules/                               # 13 reusable modules
β”‚       β”‚   β”œβ”€β”€ api-management/
β”‚       β”‚   β”œβ”€β”€ app-registrations/
β”‚       β”‚   β”œβ”€β”€ data-factory/
β”‚       β”‚   β”œβ”€β”€ function-app-flex/
β”‚       β”‚   β”œβ”€β”€ key-vaults/
β”‚       β”‚   β”œβ”€β”€ log-analytics/
β”‚       β”‚   β”œβ”€β”€ logic-app-connections/
β”‚       β”‚   β”œβ”€β”€ logic-app-standard/
β”‚       β”‚   β”œβ”€β”€ network/
β”‚       β”‚   β”œβ”€β”€ power-platform/
β”‚       β”‚   β”œβ”€β”€ power-platform-enterprise-policy/
β”‚       β”‚   β”œβ”€β”€ resource-groups/
β”‚       β”‚   └── storage-account/
β”‚       β”‚
β”‚       β”œβ”€β”€ environments/                          # Environment configs
β”‚       β”‚   └── dev/terraform.tfvars
β”‚       β”‚
β”‚       β”œβ”€β”€ bff-openapi/                           # OpenAPI specs
β”‚           └── pp-bff.json
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
└── Source/                                        # Application code
    β”œβ”€β”€ IntegrationGuide.slnx                      # Visual Studio solution
    β”‚
    β”œβ”€β”€ Azure/                                     # Azure components
    β”‚   β”œβ”€β”€ Functions/
    β”‚   β”‚   └── FnBackend/                         # .NET 8 Isolated Function App
    β”‚   β”‚       β”œβ”€β”€ Functions/                     # HTTP-triggered functions
    β”‚   β”‚       β”œβ”€β”€ Services/                      # Dataverse service client
    β”‚   β”‚       β”œβ”€β”€ Middleware/                    # OAuth2 validation
    β”‚   β”‚       └── Deployment/                    # Deployment scripts
    β”‚   β”‚           └── deploy.ps1                 # Function app code deployment script
    β”‚   β”‚
    β”‚   β”‚
    β”‚   β”‚
    β”‚   β”œβ”€β”€ LogicApps/
    β”‚   β”‚   β”œβ”€β”€ Workflows/                         # Logic App Standard workflows
    β”‚   β”‚   β”‚   β”œβ”€β”€ DataverseIntegration/
    β”‚   β”‚   β”‚   β”‚   └── workflow.json
    |   |   |   β”œβ”€β”€ DataverseTrigger/
    β”‚   β”‚   β”‚   β”‚   └── workflow.json
    β”‚   β”‚   β”‚   β”‚   
    β”‚   β”‚   β”‚   β”œβ”€β”€ host.json
    |   |   |   β”œβ”€β”€ connections.json
    |   |   |   └── parameters.json
    β”‚   β”‚   β”‚ 
    β”‚   β”‚   └── Deployment/
    |   |       └── deploy.ps1                     # Logic App Workflows deployment script
    β”‚   β”‚
    β”‚   └── AzureDataFactory/
    β”‚       β”œβ”€β”€ adf_export/                        # Exported ADF artifacts
    β”‚       β”‚   β”œβ”€β”€ datasets/                      # Dataverse datasets
    β”‚       β”‚   └── pipelines/                     # Import pipelines
    β”‚       β”œβ”€β”€ data/                              # Sample data files
    β”‚       └── Deployment/                        # Import automation
    β”‚
    └── PowerPlatform/                             # Power Platform components
        β”œβ”€β”€ Plugin/                                # Dataverse Plugin (.NET 4.6.2)
        β”‚   β”œβ”€β”€ AzKeyVaultDemoPlugin.cs            # Azure Key Vault integration
        β”‚   β”œβ”€β”€ GenericHttpClientDemoPlugin.cs     # HTTP client with MI
        β”‚   β”œβ”€β”€ PluginBase.cs
        β”‚   └── Services/
        β”‚       β”œβ”€β”€ AzKeyVaultService.cs
        β”‚       └── GenericHttpClient.cs
        β”‚
        └── Solutions/
            └── pplab01/
                β”œβ”€β”€ src_template/                  # Template with token placeholders, Unpacked solution source
                β”‚   β”œβ”€β”€ customapis/                # Custom APIs
                β”‚   β”‚   β”œβ”€β”€ kb_AzKeyVaultDemoApi/
                β”‚   β”‚   └── kb_GenericHttpClient/
                β”‚   β”œβ”€β”€ pluginpackages/
                β”‚   └── Other/
                β”œβ”€β”€ src/                           # terraform apply will output here unpacked solution with replaced tokens
                └── packed/                        # Packed solution ZIP after terraform apply command
                    

πŸš€ Quick Start

Prerequisites

  • Azure Subscription with Owner or Contributor + User Access Administrator roles
  • Power Platform License (Developer environment is FREE, or M365 trial)
  • Terraform 1.5+ (Install)
  • Azure CLI (Install)
  • Power Platform CLI (terraform power platform module requires this to configure managed environment since native tf provider has some bugs)
  • .NET 8 SDK (Install)
  • Visual Studio 2022 or VS Code (for source code development)

1️⃣ Deploy Infrastructure (5-10 minutes with minimal configuration, 30-45 minutes with all resources)

# Clone repository
git clone https://github.com/malaker/Azure-PowerPlatform-Lab.git
cd Azure-PowerPlatform-Lab/Infrastructure/terraform


# Configure environment
# Edit environments/dev/terraform.tfvars with your settings:
# - subscription_id
# - default_power_platform_owner_id (your Entra ID user GUID)
# - apim_publisher_email (if enabling APIM)

# Login to Azure
az login

# Initialize Terraform (first time only)
.\deploy.ps1 -Init -Environment dev

# Review what will be created
.\deploy.ps1 -Environment dev -Action plan

# Deploy infrastructure
.\deploy.ps1 -Environment dev -Action apply

# View outputs (URLs, client IDs, etc.)
terraform output

What gets deployed:

  • 5 Resource Groups
  • 4 App Registrations (one with federated credentials)
  • VNet with 6 subnets + NSGs
  • Key Vault (RBAC-based) that includes client id and secrets
  • Azure Function App (Flex Consumption)
  • Storage Accounts (RBAC-based)
  • Log Analytics + Application Insights
  • Power Platform Developer Environment
  • Enterprise Policy + VNet Integration

πŸ’° Default Cost: ~$0-15/month

2️⃣ Deploy Source Code

Deploy Azure Functions

cd Source/Azure/Functions/FnBackend/Deployment

#Since terraform generates everytime unique resource names either get function app name from portal azure or terraform outputs
.\deploy.ps1 -FunctionAppName <function resource name>

Deploy Logic App Workflows (optional)

cd Source/Azure/LogicApps/Deployment

.\deploy.ps1 -LogicAppStandardResourceName <logic app resource name>

Deploy Data Factory Artifacts

cd Source/Azure/AzureDataFactory/Deployment

# Import datasets and pipelines
.\deploy.ps1 -AdfResourceName <ADF resource name>

Deploy Power Platform Solution

The solution is automatically packed by Terraform if the source exists.

Deploy solution manually or using PAC CLI

πŸ’° Cost Breakdown

Current Configuration (Default terraform.tfvars)

~$0-15/month in Dev environment

Component Status Monthly Cost
Core Infrastructure (Functions*, Storage, Key Vault) βœ… Enabled ~$0 (Free tier)
Networking (VNet, NSGs, VNet Peering**) βœ… Enabled ~$0-5 (Traffic-based)
NAT Gateway ❌ Disabled Saves ~$36.50
API Management (Developer_1) ❌ Disabled Saves ~$48.04
Logic App Standard (WS1) ❌ Disabled Saves ~$197
Data Factory ❌ Disabled Saves ~$2-10
Power Platform Developer Env βœ… Enabled $0 (Free)
Subnet Delegation (Enterprise Policy) βœ… Enabled $0 (Free)

* Azure Functions (Flex Consumption Plan): Includes a generous free monthly grant of 250,000 executions and 100,000 GB-seconds per subscription. Beyond the free tier, costs are $0.000026/GB-s for execution time and $0.40 per million executions. For typical dev/demo workloads, you'll likely stay within the free tier.

** VNet Peering: Cross-region VNet peering (West Europe ↔ North Europe) incurs data transfer charges at ~$0.035/GB for both inbound and outbound traffic. VNets and NSGs themselves are free, but peering costs depend on traffic volume between regions. For minimal dev/demo traffic, costs are typically under $5/month.

All Features Enabled

~$283-295/month in Dev environment

See Infrastructure README for detailed cost analysis.

πŸŽ›οΈ Feature Flags

Control what gets deployed via environments/dev/terraform.tfvars:

# Network
enable_nat_gateway = false                           # ~$36.50/month - Static IP for whitelisting
enable_powerplatform_subnet_delegation = true        # Free - VNet integration

# Azure Services
enable_api_management = false                        # ~$48.04/month - API Gateway
enable_logic_apps = false                            # ~$197/month - Low-code workflows
enable_data_factory = false                          # ~$2-10/month - ETL/ELT pipelines

# Power Platform
power_platform_environments = [...]                  # Free for Developer

πŸ” Key Features & Integration Patterns

1. Managed Identity Authentication (No Secrets!)

Dataverse Plugin β†’ Azure Key Vault:

  • Federated Identity Credentials (Workload Identity)
  • No client secrets in code or environment variables

Dataverse β†’ Internal APIM (Optional) β†’ Azure Functions β†’ Dataverse:

  • Dataverse Plugin APIM/Function app integration using managed identity
  • Service Principal with OAuth2
  • On-Behalf-Of (OBO) flow for user context # Custom connector to be defined manually in maker portal
  • Client credentials flow for app-only scenarios

Logic Apps β†’ Dataverse:

  • Managed Identity with API Connections
  • Service Principal authentication
  • Secrets stored in Key Vault (via references)
  • Networking configuration (Firewall+VNET outbound integration) # Since Dataverse connector does not use subnet delegation, to function correctly Dataverse Trigger for Logic App it is required to whitelist either Service Tag: PowerPlatformInfra or individual Power Platform IPs which is very error prone.

Data Factory β†’ Dataverse:

  • Managed Identity with linked services
  • Service Principal authentication
  • Key Vault integration for credentials
  • VNET Integration

2. Enterprise Networking Patterns

VNet Integration:

  • Subnet delegation for Power Platform
  • Private connectivity between Azure and Dataverse
  • No public internet traversal

Network Security:

  • NSGs on all subnets
  • Network access restrictions on Functions/Logic Apps
  • Private DNS zones for internal APIM
  • Service endpoints for Key Vault and Storage

Outbound IP Control:

  • Optional NAT Gateway for static IP
  • Whitelistable IP for Power Platform IP firewall
  • Consistent outbound connectivity

3. Security Best Practices

Zero Trust Principles:

  • RBAC-based access control (no legacy access policies)
  • Managed identities everywhere (no connection strings)
  • Key Vault for all secrets
  • Network isolation with VNets

Least Privilege Access:

  • Function App: Only Key Vault Secrets User + Storage Contributor
  • Logic Apps: Only required API Connection access
  • Data Factory: Only linked service permissions
  • Power Platform SVC: Only required API permissions

API Security:

  • OAuth2 + JWT validation on Azure Functions
  • API Management with OAuth policies
  • App roles for application permissions
  • Delegated scopes for user context

πŸ§ͺ What Can You Test?

Power Platform Premium Features

  • βœ… Managed Environments
  • βœ… VNet Integration (Enterprise Policies)
  • βœ… Dataverse Plugins with Managed Identity
  • βœ… Custom APIs
  • βœ… IP Firewall with NAT Gateway (optional)

Azure Integration Patterns

  • βœ… Azure Functions with OAuth2 + OBO flow
  • βœ… Logic App Standard with Dataverse triggers
  • βœ… Data Factory ETL/ELT pipelines
  • βœ… API Management BFF pattern
  • βœ… Key Vault integration (no secrets in code!)
  • βœ… VNet private connectivity

Security Scenarios

  • βœ… Managed Identity end-to-end
  • βœ… RBAC-based access control
  • βœ… Network isolation with VNets
  • βœ… OAuth2 token validation
  • βœ… App roles + delegated permissions
  • βœ… Key Vault secret management

🧹 Cleanup

To delete all resources:

cd Infrastructure/terraform

# Destroy all infrastructure
.\deploy.ps1 -Environment dev -Action destroy

# Confirm with 'destroy-dev'

# Confirm with 'yes'

Note: Power Platform environments may have deletion protection enabled. Manually delete in Power Platform Admin Center if needed. Remember to unlink enterprise policy in the first place in case of manual deletion resources.

πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

⭐ If this repository helped you, please consider giving it a star!

About

A comprehensive lab environment for testing Power Platform premium features with Azure integration using managed identities, VNet integration, and enterprise security patterns.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors