简体   繁体   中英

Failed to send query to service connection API when using Azure devops api serviceendpoint to create kubernetes service connection

I am trying to use the https://dev.azure.com/<orgname>/_apis/serviceendpoint/endpoints?api-version=6.0-preview.4 api to create a new kubernetes service connection.

I want to use AzureSubscription auth, and as far as I know, it creates the service account and role binding for you. I have done this in portal and it works fine, but am struggling to replicate through the api.

I am able to create the Service Connection, and it sits in my service connection list in the project settings no problem.

When I pull it back down to check the status (with the GET service endpoint) , I have an operation status of 'failed' with a status message of 'An error occurred while creating the service account. Internal error: Failed to query service connection API: 'https://management.azure.com/api/v1/namespaces/default/serviceaccounts?pretty=false'. Error Message: 'An error occurred while sending the request.'

Here is what I am sending in the body, I am using a PAT to auth.

{
  "data": {
        "authorizationType": "AzureSubscription",
        "clusterAdmin": "true",
        "azureSubscriptionId": "00000000-0000-0000-0000-000000000000",
        "azureSubscriptionName": "SomeSubscriptionName",
        "clusterId": "/subscriptions/"00000000-0000-0000-0000-000000000000"/resourceGroups/someresourcegroupname/providers/Microsoft.ContainerService/managedClusters/someclustername",
        "namespace": "default"
  },
  "name": "TestK8sEndpoint",
  "type": "Kubernetes",
  "url": "https://management.azure.com/",
  "authorization": {
    "parameters": {
            "azureTenantId": ""00000000-0000-0000-0000-000000000000"",
            "azureEnvironment": "AzureCloud"
    },
    "scheme": "Kubernetes"
  },
  "isShared": false,
  "isReady": true,
  "serviceEndpointProjectReferences": [
    {
      "projectReference": {
        "id": ""00000000-0000-0000-0000-000000000000"",
        "name": "someprojectname"
      },
      "name": "TestK8sEndpoint"
    }
  ]
}

Any help is much appreciated

I have since realised that I made a mistake in my body.

The 4th property url should have been the url of my cluster - aka, someclustername-dns-0a0a0a0a.hcp.northeurope.0a0a0a.io

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM