Search code examples
c#.netgoogle-cloud-platformgoogle-cloud-functionscloud

How to list GCP project labels in Cloud function?


Below documentation has details for accessing various GCP resources but not GCP project. I am interested in listing all the labels of a GCP project using .net API.

https://cloud.google.com/dotnet/docs/reference

Any references/links will be helpful


Solution

  • Found the solution.

            Google.Cloud.ResourceManager.V3.ProjectsClient projectsClient = await Google.Cloud.ResourceManager.V3.ProjectsClient.CreateAsync();
            Google.Cloud.ResourceManager.V3.Project response = await projectsClient.GetProjectAsync("projects/83446985491");
            //response.Labels;
    

    Source: https://cloud.google.com/dotnet/docs/reference/Google.Cloud.ResourceManager.V3/latest/Google.Cloud.ResourceManager.V3.Projects.ProjectsClient