Power BI Embedded ile CRM ekranına custom rapor nasıl eklenir?
Dynamics 365 CRM ekranlarına Power BI raporu gömmek, kurumsal karar alma süreçlerini hızlandırır ve operasyonel veriye analitik katma değer sağlar. Bu makalede Power BI Embedded mimarisi ile CRM ekranına dinamik, kullanıcı bazlı filtrelenmiş rapor entegrasyonunun nasıl yapılacağını görsellerle destekleyerek adım adım anlatıyoruz.
Genel Konsept
CRM → Backend API → Azure AD → Power BI → Embed Token → Rapor
1. Proje Amacı
| Hedef 🎯 | Açıklama |
|---|---|
| CRM ekranına rapor embed | WebResource (HTML/JS) veya PCF |
| Kullanıcı bazlı gösterim | RLS ve CRM bilgilerinin entegrasyonu |
| Güvenlik | Azure AD + CRM Security model |
| Performans | DirectQuery / Incremental Refresh |
| Yönetilebilirlik | Power BI Service üzerinden |
2. Azure AD Kurulumu
Azure Portal → App Registrations → “New Application”
| Ayar | Değer |
|---|---|
| API Permissions | Dataset.Read.All, Report.Read.All |
| Authentication | Client Credentials |
| Gereken Bilgi | TenantId, ClientId, Secret |
3. Power BI RLS Tanımı
[CRMLookupId] = USERPRINCIPALNAME()
📌 CRM’de oturum açmış kullanıcının domain bilgisinin dataset’te karşılığı olmalıdır.
4. Backend’de Embed Token Üretimi
public async Task<string> GetEmbedToken(string reportId, string workspaceId)
{
var credentials = new TokenCredentials(GetAccessToken(), "Bearer");
var pbiClient = new PowerBIClient(new Uri("https://api.powerbi.com/"), credentials);
var tokenRequest = new GenerateTokenRequest(
accessLevel: "View",
identities: new List<EffectiveIdentity>
{
new EffectiveIdentity("crm_user", new List<string> { "crm_dataset" })
}
);
var tokenResponse = await pbiClient.Reports.GenerateTokenAsync(workspaceId, reportId, tokenRequest);
return tokenResponse.Token;
}
5. CRM WebResource İçeriği
<script src="https://cdn.powerbi.com/libs/powerbi-client/2.22.1/powerbi.js"></script>
<div id="pbi-container" style="height:600px;"></div>
<script>
function loadPowerBI(accessToken, reportId, embedUrl) {
var config = { type: "report", id: reportId, embedUrl, accessToken };
powerbi.embed(document.getElementById("pbi-container"), config);
}
</script>
6. JavaScript ile CRM’den Dinamik Veri Gönderimi
function LoadReport() {
var employeeId = Xrm.Page.getAttribute("hs_employeeid").getValue()[0].id;
$.get("/api/powerbi/embedtoken?employeeId=" + employeeId, function(r) {
loadPowerBI(r.token, r.reportId, r.embedUrl);
});
}
7. Entegrasyon Süreci
CRM ekranı → JS → Backend (.NET Core) → Azure AD → Power BI → Embed → Kullanıcıya özel gösterim
8. Performans İpuçları
| Seçenek | Ne zaman? |
|---|---|
| DirectQuery | Canlı veri |
| Import | Hız öncelikli |
| Incremental Refresh | Büyük dataset |
| Filtreleme | Sadece ilgili verinin yüklenmesi |
9. Lisanslama
| Lisans Türü | Uygunluk |
|---|---|
| Power BI Pro | ❌ Embed desteklemez |
| Premium Per User | 🔍 Test ortamlarında |
| Premium Capacity | 🚀 Production için gerekli |
10. Mimari Akış Özeti
CRM → JavaScript → Backend → AzureAD → Power BI Token → CRM içi rapor
11. Sonuç
| Özellik | Durum |
|---|---|
| CRM içine embed | ✔ |
| Kullanıcı bazlı veri | ✔ |
| Güvenlik | ✔ |
| Performans | ✔ |
| Enterprise kullanıma uygun | ✔ |
👤 Yazar
Oğuzhan Aşan
Microsoft Dynamics 365 & Power Platform Specialist


Top comments (0)