如何在Azure PowerShell函数中导入模块?

时间:2019-07-03 10:31:11

标签: function azure powershell azure-storage

我正在尝试从一个函数查询azure表(使用Get-AzTableRow)。从我的笔记本电脑上可以很好地工作,但是azure功能中没有模块“ aztable”,因此我得到的只是一个红色屏幕:( 有安装的方法吗?

谢谢! 大卫

2 个答案:

答案 0 :(得分:0)

Azure PowerShell已安装或更新,必须安装模块AzTable,该模块具有用于管理实体的命令。要安装此模块,请以管理员身份运行PowerShell并使用Install-Module命令。 您可以参考本文中提到的建议。 https://docs.microsoft.com/en-us/azure/storage/tables/table-storage-how-to-use-powershell

请参阅https://docs.microsoft.com/en-us/azure/azure-functions/supported-languages

AzTable模块:Azure函数中支持的语言powershellgallery.com/packages/AzTable/2.0.1

请告知我们以上内容是否对您有帮助,或者您在此问题上需要进一步的帮助。

答案 1 :(得分:0)

您不需要自己在Azure函数中安装AzTable模块。运行命令时,它将为您安装相应的模块。

以下是屏幕截图:

enter image description here

AzTable模块的示例:

$location = "eastus"
$resourceGroup = "charlesTable11"
New-AzResourceGroup -ResourceGroupName $resourceGroup -Location $location
$storageAccountName = "pshtablestorage1122"
$storageAccount = New-AzStorageAccount -ResourceGroupName $resourceGroup `
  -Name $storageAccountName `
  -Location $location `
  -SkuName Standard_LRS `
  -Kind Storage

$ctx = $storageAccount.Context
$tableName = "pshtesttable"
New-AzStorageTable –Name $tableName –Context $ctx
Get-AzStorageTable –Context $ctx | select Name

enter image description here