Azure Search不提供任何计划的扩展选项,因此我尝试通过自动化帐户创建它。
我跟着AzSearch PowerShell command,但它没有按照我的预期运作。
带有Set-AzureRmResource
参数的 ReplicaCount=2
未应用。实际上,它没有给出任何结果消息。我错过了什么?
要重现我的问题,您可以在以下链接导入我的Runbook文件;
https://gist.github.com/YoungjaeKim/5cb66a666a3a864b7379aac0a400da40
将文本文件另存为AzureSearch-SetReplicaCount.graphrunbook
并将其导入自动化帐户>添加Runbook菜单。
答案 0 :(得分:0)
在评论者之后,我最终制作了PowerShell Runbook。
我将powershell源代码上传到以下链接;
https://gallery.technet.microsoft.com/scriptcenter/Azure-Search-change-c0b49c4c
让我附上如下代码;
<#
.DESCRIPTION
Scale Azure Search ReplicaCount
AzSearch command reference; https://docs.microsoft.com/en-us/azure/search/search-manage-powershell
.NOTES
AUTHOR: Youngjae Kim
LASTEDIT: June 19, 2017
#>
Param(
[string]$SubscriptionId,
[string]$ResourceGroupName,
[string]$AzSearchResourceName,
[int]$InstanceCount = 1
)
# 1. Acquire Automation account
$connectionName = "AzureRunAsConnection"
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. You must have Automation account. Reference: https://docs.microsoft.com/en-us/azure/automation/automation-role-based-access-control"
throw $ErrorMessage
} else{
Write-Error -Message $_.Exception
throw $_.Exception
}
}
# 2. Select subscription
Select-AzureRmSubscription -SubscriptionId $SubscriptionId
# 3. Specify Azure Search Resource
$resource = Get-AzureRmResource `
-ResourceType "Microsoft.Search/searchServices" `
-ResourceGroupName $ResourceGroupName `
-ResourceName $AzSearchResourceName `
-ApiVersion 2015-08-19
Write-Output ($resource)
# 4. Scale your service up
# Note that this will only work if you made a non "free" service
# This command will not return until the operation is finished
Write-Output ("Updating InstanceCount to " + $InstanceCount + ". This can take 15 minutes or more...")
$resource.Properties.ReplicaCount = $InstanceCount
$resource | Set-AzureRmResource -Force -Confirm:$false
# 5. Finish
Write-Output ("End of Process to set InstanceCount = " + $InstanceCount + " for " + $AzSearchResourceName)