使用Power脚本创建Easy Tables

时间:2018-04-13 06:39:18

标签: powershell azure azure-sql-database azure-mobile-services offline

有没有办法通过PowerShell而不是JS文件定义Easy Tables。?

通过CSV创建Easy表的任何示例或有关通过JS文件定义的文档都会有所帮助。

1 个答案:

答案 0 :(得分:1)

我们可以使用Rest API创建Easy表并将数据导入easy表。我用Postman测试它。

创建简易表格

https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/tomtestmobile/extensions/Microsoft.Mobile.Management/tables?api-version=2014-11-01

身体样本:

{"name":"tableName","permissions":[{"name":"read","level":"anonymous"},{"name":"insert","level":"anonymous"},{"name":"update","level":"anonymous"},{"name":"delete","level":"anonymous"},{"name":"undelete","level":"anonymous"}],"links":[],"insert":"","update":"","delete":"","read":"","undelete":"","hasCustomPermissions":false,"extendedSettings":{"softDelete":true},"columns":[{"name":"Team","type":"String"},{"name":"Product","type":"String"},{"name":" name","type":"String"}]}

enter image description here

导入数据 enter image description here

https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/tomtestmobile/extensions/Microsoft.Mobile.Management/tables/JustForTest3/data?api-version=2014-11-01

身体样本:

{"csvData":"Team,Cover Product, name\r\nCloud,Azure ,tom"}

Plesae在Powershell中使用以下代码调用rest API。如何获得授权,您可以参考此video

  $body = "jsonstring"
  $hdrs = @{}
  $hdrs.Add("Authorization","Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1d...")
  Invoke-RestMethod -Uri $url -Method Post -Body $body -ContentType 'application/json' -Headers $hdrs