2017-06-16 23 views
0

Azure搜索不提供任何计划缩放选项,因此我尝试通过自动化帐户进行设置。Azure搜索集自动化图形操作手册ReplicaCount

我跟着AzSearch PowerShell command,但它没有按预期工作。

Set-AzureRmResourceReplicaCount=2参数不适用。实际上,它不会给出任何结果消息。我错过了什么?

重现我的问题,你可以导入我的runbook文件在下面的链接;

https://gist.github.com/YoungjaeKim/5cb66a666a3a864b7379aac0a400da40

将文本文件保存为AzureSearch-SetReplicaCount.graphrunbook然后将其导入到自动化帐户>添加运行手册菜单。

+0

男人,图行事历是废话。你甚至不能告诉它在导入之前做了什么。所以你是否手动尝试过你的命令?它工作吗? – 4c74356b41

+0

@ 4c74356b41 //好吧,我还没有尝试使用原始的PowerShell命令。也许我必须通过PS Command自动化来完成。 – Youngjae

+0

只需从电脑\笔记本电脑上尝试没有运行手册的命令。并查看它是否正常工作,从那里开始排除故障 – 4c74356b41

回答

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)