Azure Synapse 专用终结点批准

Azure Synapse Private Endpoint Approve

通过 CICD 进程中的一些 Terraform 脚本,我正在尝试为 Azure SQL 服务器链接服务创建托管私有端点。使用以下代码成功:

resource "azurerm_synapse_managed_private_endpoint" "mi_metadata_transform_sql_server_private_endpoint" {
name                 = "mi_synapse_metadata_transform_private_endpoint"
subresource_name     = "sqlServer"
synapse_workspace_id = module.mi_synapse_workspace.synapse_workspace_id
target_resource_id   = azurerm_mssql_server.mi-metadata-transform-sql-server.id}

但这会使端点处于“待批准状态”。因此,添加下面的代码是基于我们现有的一些代码,这些代码通过 Bash 批准了一些存储,我决定复制该代码并针对 SQL 服务器进行相应的调整。这就是我的问题开始的地方......

function enable_sql_private_endpoint {
        endpoints=$(az sql server show --name  -g ${{ parameters.resourceGroupName }} --subscription $(serviceConnection) --query  "privateEndpointConnections[?properties.privateLinkServiceConnectionState.status=='Pending'].id" -o tsv)        
        for endpoint in $endpoints 
        do
          az sql server private-endpoint-connection approve --account-name  --name $endpoint --resource-group ${{ parameters.resourceGroupName }} --subscription  $(serviceConnection)
        done
        }


    sqlServers="$(az sql server list -g ${{ parameters.resourceGroupName }} --query '[].name' --subscription $(serviceConnection) -o tsv)"

    for sqlServerName in $sqlServers
    do
        echo "Processing $sqlServerName ========================================="
        enable_sql_private_endpoint  $sqlServerName
    done

上面的代码在 YAML 文件中进一步执行,用最简单的术语来说:

问题出在 az sql server private-endpoint-connection approve 并且它不存在。当我查看此 link 时,我看不到任何远程内容,例如 SQL 服务器端点的批准选项,如存储或 MySQL 所具有的。对于如何实现这一点,我们将不胜感激

Currently, you can't approve a Managed Private Endpoint using Terraform.

注意: Azure PowerShellAzure CLI 是在 Microsoft 合作伙伴服务或客户拥有的服务上管理专用终结点连接的首选方法。

详情请参考Manage Private Endpoint connections on a customer/partner owned Private Link service

最后,这就是我在我的 YAML / Bash 中使用的方法:

        sqlServers="$(az sql server list -g ${{ parameters.resourceGroupName }} --query '[].name' --subscription $(serviceConnection) -o tsv)"

    for sqlServerName in $sqlServers
    do
      echo "Processing $sqlServerName ========================================="
      enable_sql_private_endpoint  $sqlServerName
    done

        function enable_sql_private_endpoint {
    endpoints=$(az sql server show --name  -g ${{ parameters.resourceGroupName }} --subscription $(serviceConnection) --query  "privateEndpointConnections[?properties.privateLinkServiceConnectionState.status=='Pending'].id" -o tsv)        
    for endpoint in $endpoints 
    do
      az network private-endpoint-connection approve -g  ${{ parameters.resourceGroupName }} --subscription $(serviceConnection) --id $endpoint  --type Microsoft.Sql/servers --description "Approved" --resource-name 
    done
    }

如果有人在使用 Syanpse 和托管私有端点的 CICD 中遇到类似情况,则以下行是要使用的关键语法:

az storage account private-endpoint-connection approve --account-name  --name $endpoint --resource-group ${{ parameters.resourceGroupName }} --subscription  $(serviceConnection)