English 中文(简体)
职业介绍所
原标题:Connect to Azure AI Translator in Azure DevOps Pipelines using Workload Identity Federation

I would like to use the Azure AI Text Translation from an Azure DevOps build pipeline, without having to use any secrets for authentication. I have used Workload Identity Federation for smooth authentication from pipelines before, so if that is possible also for Azure AI Translator that would be great.

I have set up a resource group in Azure Portal with a resource of type Translator . I have also set up a (Azure Resource Manager) service connection in my Azure DevOps project that is referring to that resource group, and I can see that a federated credential was created for me in Microsoft Entra.

Now the next step is usually to set up permissions for the federated credential in Microsoft Entra. For my previous federated credential, I have used "Request API permissions". But there it is not obvious what to select in this case. I could use some guidance on how to set up the permissions to be able to use Text Translation from my pipeline.

问题回答

“DevOps”管道被用于“CICD”进程。 如对笔译员而言,请使用<代码>KEY、<代码>Reg和Web Api而不是用于自动化的工作载荷识别联合会。

快速启动方案

Translator 3.0: Translate

“entergraph

日元样本:

pool:
  vmImage: Windows-latest

steps:
- task: PowerShell@2
  inputs:
    targetType:  inline 
    script: |
      # Define the paramters to translate a string
          $subscriptionKey = ${env:KEY}
          $region = "eastus"
          $text = "Hello, world!"
          $toLanguage = "fr"
      # Define the function to call the Translator Text API
          function Translate-Text ($subscriptionKey, $region, $text, $toLanguage) {
              $uri = "https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=$toLanguage"
              $headers = @{
                  "Ocp-Apim-Subscription-Key" = $subscriptionKey
                  "Ocp-Apim-Subscription-Region" = $region
                  "Content-Type" = "application/json"
              }
              $body = ConvertTo-Json @(@{ Text = $text })
      
              $response = Invoke-RestMethod -Uri $uri -Method Post -Body $body -Headers $headers
              return $response[0].translations[0].text
          }
          $translatedText = Translate-Text -subscriptionKey $subscriptionKey -region $region -text $text -toLanguage $toLanguage
          Write-Output "Translated text: $translatedText"
  env:
    KEY: $(key)

产出转化为:

“entergram





相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Remotely authenticating client Windows user on demand

Suppose I am writing a server for a particular network protocol. If I know that the client is running on a Windows machine, is it possible for my server to authenticate the Windows user that owns the ...

Role/Permission based forms authorizing/authentication?

While looking into forms authorizing/authentication, I found that it is possible to do role based authorizing by adding an array of roles to a FormsAuthenticationTicket. That way I can write User....

热门标签