azureazure-ai-search

ERROR: () The provided value for encryptionWithCmk.enforcement were invalid while trying to update azure search service


I am trying to update the network rules of a search service using the following powershell command:az search service update --name "$(azure_search_service)" --resource-group "$(resource_group)" --ip-rules $ipsToBeAdded

but getting the error "ERROR: () The provided value for encryptionWithCmk.enforcement were invalid.

Parameter name: encryptionWithCmk Code: Message: The provided value for encryptionWithCmk.enforcement were invalid.

Parameter name: encryptionWithCmk"

This issue is happening when, we delete the existing search service, and deploy it again using the same powershell command which is "New-AzSearchService -ResourceGroupName "$ResourceGroupName" -Name "$ServiceName" -Sku "$Sku" -Location "$Location" -HostingMode "$HostingMode"" and trying to update the firewall with certain IPs.

Edit: I am trying to deploy this in a pipeline, creation of search service is done in a separate task(using azure powershell) and adding an IP to it is being done in another task(using azure cli).


Solution

  • You do az login and try below command.

    az search service update --name "powershell" --resource-group "resourcegrp_name" --ip-rules "49.37.180.224"

    Output:

    enter image description here

    Or

    do Connect-AzAccount in PowerShell and execute below script.

    $newIpRules = @("49.37.180.224","49.37.180.223")
    
    Set-AzSearchService  -ResourceGroupName "resourcegrp_name" -Name "sample789" -IPRuleList $newIpRules
    

    Note: You need to install minimum Az.Search 0.10.0 version.

    Use this command to install. Install-Module -Name Az.Search -RequiredVersion 0.10.0

    enter image description here