Power BI - Call Azure API with nextLink (next page)

前端 未结 1 1064
伪装坚强ぢ
伪装坚强ぢ 2021-01-16 22:09

Apologies, I\'m new to Power BI. I\'m using Power BI to call an Azure API that will list all the VMs in my subscription, however it will only show the first 50 before having

相关标签:
1条回答
  • 2021-01-16 22:34

    For anyone interested, here is what I ended up doing thanks to this link:

    https://datachant.com/2016/06/27/cursor-based-pagination-power-query/

    let
        iterations = 10,
        url = 
         "https://management.azure.com/subscriptions/< subscription >/providers/Microsoft.Compute/virtualMachines?api-version=2017-12-01",
    
        FnGetOnePage =
         (url) as record =>
          let
           Source = Json.Document(Web.Contents(url)),
           data = try Source[value] otherwise null,
           next = try Source[nextLink] otherwise null,
           res = [Data=data, Next=next]
          in
           res,
    
        GeneratedList =
         List.Generate(
          ()=>[i=0, res = FnGetOnePage(url)],
          each [i]<iterations and [res][Data]<>null,
          each [i=[i]+1, res = FnGetOnePage([res][Next])],
          each [res][Data])
        in
         GeneratedList
    

    1 whole day of Googling headache :S

    0 讨论(0)
提交回复
热议问题