如何使用 AzureRM 从 Azure 存储 Table 查询实体?
How to query entities from Azure Storage Table with AzureRM?
我有几个 Azure Runbook,它们使用 AzureRM
根据某些配置自动扩展服务计划。
该配置作为 table 中的实体保存在我的 Azure 存储帐户中。
但是,我找不到在我的运行手册中使用 AzureRM
从 table 中读取实体的方法...
我不能使用任何 Az
模块,因为它会抱怨在 Az
旁边还导入 AzureRM
。而且我不想拥有 2 个单独的自动化帐户,只是为了能够同时使用 AzureRM
和 Az
。
那么有没有什么方法可以使用 AzureRM
模块从 Azure 存储 Table 中获取所有实体?
根据我的测试,如果你想使用 AzureRm
模块从 Azure 存储 Table 中获取所有实体,你可以使用模块 AzureRmStorageTable
。但请注意,它的版本只低于 1.0.0.23。详情请参考https://github.com/paulomarquesc/AzureRmStorageTable/blob/master/ReleaseNotes.md.
例如:
try
{
# Get the connection "AzureRunAsConnection "
$servicePrincipalConnection=Get-AutomationConnection -Name $connectionName
"Logging in to Azure..."
Add-AzureRmAccount `
-ServicePrincipal `
-TenantId $servicePrincipalConnection.TenantId `
-ApplicationId $servicePrincipalConnection.ApplicationId `
-CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint
}
catch {
if (!$servicePrincipalConnection)
{
$ErrorMessage = "Connection $connectionName not found."
throw $ErrorMessage
} else{
Write-Error -Message $_.Exception
throw $_.Exception
}
}
$table = Get-AzureStorageTableTable -resourceGroup jimtest -tableName SchemasTable -storageAccountName jimtestdiag417
Get-AzureStorageTableRowAll -table $table
更新
关于如何为Azure Automation 账户安装特殊版本模块,您可以通过page 进行。
感谢 Michale B. 对我的问题的评论,以下解决了我的问题:
Could also make use of the alias option in the Az module. docs.microsoft.com/en-us/powershell/module/az.accounts/… . This will allow you to use (most) AzureRM functions, while also using the Az module
我有几个 Azure Runbook,它们使用 AzureRM
根据某些配置自动扩展服务计划。
该配置作为 table 中的实体保存在我的 Azure 存储帐户中。
但是,我找不到在我的运行手册中使用 AzureRM
从 table 中读取实体的方法...
我不能使用任何 Az
模块,因为它会抱怨在 Az
旁边还导入 AzureRM
。而且我不想拥有 2 个单独的自动化帐户,只是为了能够同时使用 AzureRM
和 Az
。
那么有没有什么方法可以使用 AzureRM
模块从 Azure 存储 Table 中获取所有实体?
根据我的测试,如果你想使用 AzureRm
模块从 Azure 存储 Table 中获取所有实体,你可以使用模块 AzureRmStorageTable
。但请注意,它的版本只低于 1.0.0.23。详情请参考https://github.com/paulomarquesc/AzureRmStorageTable/blob/master/ReleaseNotes.md.
例如:
try
{
# Get the connection "AzureRunAsConnection "
$servicePrincipalConnection=Get-AutomationConnection -Name $connectionName
"Logging in to Azure..."
Add-AzureRmAccount `
-ServicePrincipal `
-TenantId $servicePrincipalConnection.TenantId `
-ApplicationId $servicePrincipalConnection.ApplicationId `
-CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint
}
catch {
if (!$servicePrincipalConnection)
{
$ErrorMessage = "Connection $connectionName not found."
throw $ErrorMessage
} else{
Write-Error -Message $_.Exception
throw $_.Exception
}
}
$table = Get-AzureStorageTableTable -resourceGroup jimtest -tableName SchemasTable -storageAccountName jimtestdiag417
Get-AzureStorageTableRowAll -table $table
更新
关于如何为Azure Automation 账户安装特殊版本模块,您可以通过page 进行。
感谢 Michale B. 对我的问题的评论,以下解决了我的问题:
Could also make use of the alias option in the Az module. docs.microsoft.com/en-us/powershell/module/az.accounts/… . This will allow you to use (most) AzureRM functions, while also using the Az module