Skip to main content

Microsoft Ads

The microsoft_ads connector reads reports and entities from the Microsoft Advertising API. It follows the same declarative shape as every StreamWright connector.

Auth​

source.yaml
spec:
config:
account_id: { type: string }
secrets:
microsoft_ads_credentials: { type: string } # OAuth + developer token (one secret)
auth:
provider: microsoft_ads
account_id: "{{ config.account_id }}"
credentials: "{{ secrets.microsoft_ads_credentials }}"

Reading data​

streams/campaigns.yaml
requests:
- name: raw_campaign_performance
sdk: microsoft_ads
service: ReportingService
method: report
arguments:
report: CampaignPerformance
columns: [AccountId, CampaignId, CampaignName, Impressions, Clicks, Spend]
window: { from: "{{ window.start }}", to: "{{ window.end }}" }

transform:
mode: page
steps:
- name: campaigns
select: |
SELECT
record->>'AccountId' AS account_id,
record->>'CampaignId' AS campaign_id,
record->>'CampaignName' AS campaign_name,
coalesce((record->>'Impressions')::BIGINT, 0) AS impressions,
coalesce((record->>'Clicks')::BIGINT, 0) AS clicks,
coalesce((record->>'Spend')::DOUBLE, 0) AS spend
FROM raw_campaign_performance

export:
campaigns:
step: campaigns
primary_key: [account_id, campaign_id]

Reference streams (examples)​

The starter template (examples/sources/ads/microsoft_ads) includes the following reference streams:

StreamDescriptionService / Report
campaignsCampaign settings, budgets, and statusesCampaignManagementService
ad_groupsAd groups within campaignsCampaignManagementService
ad_group_treeMulti-request hierarchy linking campaigns with child ad groupsCampaignManagementService
campaign_performanceDaily delivery metrics (impressions, clicks, spend)ReportingService (CampaignPerformance)
keywordsTargeted keywords, match types, and bidsCampaignManagementService
audience_targetsRemarketing lists and audience associationsCampaignManagementService
location_targetsGeographic target criteriaCampaignManagementService
Customizable Streams

These streams are reference examples. Because streams in StreamWright are declarative, you can customize columns, add additional SOAP entities or reports, or adjust DuckDB SQL transformations to fit your needs.

Shared vocabulary​

microsoft_ads maps its streams to the same canonical nodes as the other ad networks, so one pipeline covers all three.

See the connector's folder in the repo for the full option list and exact credential fields.