0

存在将用户添加到Time Series Insightsusing的手动方法Data Access Policies
尽管如此,无法批量添加用户。

在此处输入图像描述

这两个场景都可以使用脚本/自动化PowerShell/Azure REST API/SDK吗?

4

1 回答 1

0

根据我的研究,我们可以使用以下 Azure Rest API 在时序见解策略中创建数据访问策略。更多详细信息,请参阅文档

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.TimeSeriesInsights/environments/{environmentName}/accessPolicies/{accessPolicyName}?api-version=2018-08-15-preview

例如

Connect-AzAccount



$tenantId="<your tenant id>"
$resource="https://management.core.windows.net/"



$context=Get-AzContext 



$token=$context.TokenCache.ReadItems() |Where-Object { ($_.TenantId -eq $tenantId) -and ($_.Resource -eq $resource)  }
$accesstoken=$token.AccessToken
$body =@{
 "properties" = @{

  "principalObjectId" ="<the object id of the user or service principal>"
  "roles"= @("Reader")
  "description"="reader" 
 }



}| ConvertTo-Json



$url="https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.TimeSeriesInsights/environments/{environmentName}/accessPolicies/{accessPolicyName}?api-version=2018-08-15-preview"
$result =Invoke-RestMethod -Uri $url  -Method Put -Headers @{"Authorization" = "Bearer $accesstoken"} -Body $body -UseBasicParsing



$result.properties

在此处输入图像描述

于 2020-03-18T02:00:34.147 回答