【问题标题】:Azure Search set ReplicaCount by Automation graphical runbookAzure 搜索集 ReplicaCount by Automation 图形运行手册
【发布时间】:2017-06-21 11:50:09
【问题描述】:

Azure 搜索没有提供任何计划的扩展选项,所以我尝试通过自动化帐户进行。

我关注了AzSearch PowerShell command,但它并没有像我预期的那样工作。

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

要重现我的问题,您可以在下面的链接中导入我的 Runbook 文件;

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

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

【问题讨论】:

  • 伙计,图表运行手册是垃圾。您甚至无法在导入之前说出它的作用。那么您是否手动尝试过您的命令?有用吗?
  • @4c74356b41 // 好吧,我还没有尝试使用原始 PowerShell 命令。也许我必须通过 PS 命令自动化来完成。
  • 只需从您的 pc\laptop 尝试您的命令,无需运行手册。看看它是否有效,从那里开始排除故障
  • 感谢您的评论
  • 缩放 Azure 搜索服务不是即时的。更改副本计数后,您需要使用 Get-AzureRmResource 轮询搜索服务,直到其状态指示它处于“运行”状态而不是“预配”状态。我不知道如何在图形运行手册中做到这一点。我同意@4c74356b41 - 请先在 PowerShell 中直接尝试,如果它不起作用,请告诉我们。

标签: powershell azure azure-cognitive-search azure-automation


【解决方案1】:

根据评论者,我最终制作了 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) 

【讨论】:

    猜你喜欢
    • 2021-12-21
    • 1970-01-01
    • 1970-01-01
    • 2016-06-17
    • 1970-01-01
    • 1970-01-01
    • 2019-07-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多