【发布时间】:2021-02-04 18:12:32
【问题描述】:
运行set_my_tag(resources_to_tag) 出现错误
eval(expr, p) 中的错误:找不到对象“资源”
library(tidyverse)
library(AzureRMR)
#> Warning: package 'AzureRMR' was built under R version 3.6.3
#>
#> Attaching package: 'AzureRMR'
#> The following object is masked from 'package:purrr':
#>
#> is_empty
set_my_tag <- function(resources_to_tag) {
for (i in 1:nrow(resources_to_tag)) {
resource <- resources_to_tag[i, ]
az$
get_subscription(resource$subscriptionid)$
get_resource_group(resource$resourcegroup)$
get_resource(type = resource$type, name = resource$name)$
set_tags(MYTAG = resource$new_tag)
}
}
resources_to_tag <-
tribble(
~name, ~resourcegroup, ~subscriptionid, ~type, ~new_tag,
"resource name", "resource group", "subscription id", "resource type", "new tag"
)
由reprex package (v0.3.0) 于 2021-02-04 创建
虽然我执行以下操作(不将我的代码放入函数中),但一切正常。
resource <- resources_to_tag[1, ]
az$
get_subscription(resource$subscriptionid)$
get_resource_group(resource$resourcegroup)$
get_resource(type = resource$type, name = resource$name)$
set_tags(MYTAG = resource$new_tag)
此外,这是最奇怪的部分,如果我从 set_my_tag() 函数中删除 set_tag() 它可以正常工作:
set_my_tag <- function(resources_to_tag) {
for (i in 1:nrow(resources_to_tag)) {
resource <- resources_to_tag[i, ]
az$
get_subscription(resource$subscriptionid)$
get_resource_group(resource$resourcegroup)$
get_resource(type = resource$type, name = resource$name)
}
}
set_my_tag(resources_to_tag)
你知道出了什么问题吗?
【问题讨论】: