azure - Power BI - 使用 nextLink 调用 Azure API(下一页)

标签 azure powerbi azure-api-management

抱歉,我是 Power BI 新手。我正在使用 Power BI 调用 Azure API,该 API 将列出我的订阅中的所有虚拟机,但它只会显示下一个链接之前的前 50 个虚拟机。

这是我正在调用的 API;

https://management.azure.com/subscriptions/< subscription >/providers/Microsoft.Compute/virtualMachines?api-version=2017-12-01

我见过其他页面和论坛也有类似问题(例如 Microsoft API ),但没有针对 Azure API。我搞乱了他们的修复,但无法弄清楚如何将其应用到我的修复中。

他们的代码;

let
GetUserInfo = (Path)=>
let
     Source = Json.Document(Web.Contents(Path)),
     LL= @Source[value], 
     result = try @LL & @GetUserInfo(Source[#"@odata.nextLink"]) otherwise @LL

in
result,
    Fullset = GetUserInfo("https://graph.microsoft.com/beta/users?$select=manager&$expand=manager"),
    #"Converted to Table" = Table.FromList(Fullset, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"id", "displayName", "manager"}, {"Column1.id", "Column1.displayName", "Column1.manager"}),
    #"Expanded Column1.manager" = Table.ExpandRecordColumn(#"Expanded Column1", "Column1.manager", {"id", "displayName"}, {"id", "displayName"}),
    #"Renamed Columns" = Table.RenameColumns(#"Expanded Column1.manager",{{"Column1.displayName", "Employee Full Name"}, {"Column1.id", "Employee Id"}, {"id", "Manager Id"}, {"displayName", "Manager Full name"}})
in
    #"Renamed Columns"

与我通过简单的网络链接连接源后的开始相比;

let
    Source = Json.Document(Web.Contents("https://management.azure.com/subscriptions/< subscription >/providers/Microsoft.Compute/virtualMachines?api-version=2017-12-01")),
    #"Converted to Table" = Record.ToTable(Source)
in
    #"Converted to Table"

如果我要调整它,我怀疑它会看起来像这样;

let
GetUserInfo = (Path)=>
let
     Source = Json.Document(Web.Contents(Path)),
     LL= @Source[value], 
     result = try @LL & @GetUserInfo(Source[#"@odata.nextLink"]) otherwise @LL

in
result,
    Fullset = GetUserInfo("https://management.azure.com/subscriptions/< subscription >/providers/Microsoft.Compute/virtualMachines?api-version=2017-12-01"),
    #"Converted to Table" = Record.ToTable(Source)
in
    #"Converted to Table"

但是单击“确定”后,系统提示我出现以下错误;

Expression.Error: The name 'Source' wasn't recognized.  Make sure it's spelled correctly.

对此的任何帮助将不胜感激。

最佳答案

对于任何感兴趣的人,这就是我通过此链接最终所做的事情:

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

一整天的谷歌搜索头痛:S

关于azure - Power BI - 使用 nextLink 调用 Azure API(下一页),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48771173/

相关文章:

azure - 无法通过端口 445 访问 Azure 存储帐户

powerbi - 在 Power BI/Power Query 中添加缺失的日期行并获取上面行的值

powerbi - 在 Power BI 中隐藏 Logo 栏

file - PowerBi-Powerquery : If Folder/File we are loading from a path doesn't exist, change path

Azure api 管理克隆 API

visual-studio-2012 - 尝试发布时缺少根元素

python - 未使用 Python 在 MS Fabric API 中为服务主体 token 授予身份验证

azure - 如何在Graph API中按lastModifiedDateTime或lastModifiedBy用户displayName进行排序?

azure - 为什么 Azure APIM 中的 API 有多种产品?

azure - 有没有办法通过 Azure API 管理中的订阅来改变速率限制值