Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we public AzureKeyCredentialPolicy and move it to Azure.Core? #39490

Open
chunyu3 opened this issue Oct 25, 2023 · 1 comment
Open

Can we public AzureKeyCredentialPolicy and move it to Azure.Core? #39490

chunyu3 opened this issue Oct 25, 2023 · 1 comment
Labels
Azure.Core Client This issue points to a problem in the data-plane of the library. System.ClientModel Base Core library
Milestone

Comments

@chunyu3
Copy link
Member

chunyu3 commented Oct 25, 2023

There are many services which use Azure-Key for authentication. see following

@useAuth(ApiKeyAuth<ApiKeyLocation.header, "Ocp-Apim-Subscription-Key">)
@useAuth(BearerAuth)
@server(
    "{endpoint}/computervision",
    "Analyze an image to generate a description of its content.",
    {
      @doc("""
  Supported Cognitive Services endpoints (protocol and hostname, for example:
  https://<resource-name>.cognitiveservices.azure.com).
  """)
      endpoint: url,
    }
  )

In the generated SDKs, we will create AzureKeyCredentialPolicy for this authentication and add it to the Azure Core Pipeline.

_pipeline = HttpPipelineBuilder.Build(options, Array.Empty<HttpPipelinePolicy>(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader) }, new ResponseClassifier());

It will fail to build the SDK because AzureKeyCredentialPolicy is internal.
image

Workaround:
service team need manually add <Compile Include="$(AzureCoreSharedSources)AzureKeyCredentialPolicy.cs" LinkBase="Shared/Core" /> in project file(.csproj).

Affect:
It breaks sdk automation and need extra manual work for service team after he generate the SDK.

Solution:
If AzureKeyCredentialPolicy is public class and included in Azure.Core library as BearerTokenAuthenticationPolicy, the class will be automatically loaded and do not need to manually update the project file.

Can we make AzureKeyCredentialPolicy public class and include in Azure.Core as BearerTokenAuthenticationPolicy?

@jsquire jsquire added the Client This issue points to a problem in the data-plane of the library. label Oct 25, 2023
@annelo-msft annelo-msft added the System.ClientModel Base Core library label Apr 9, 2024
@annelo-msft annelo-msft added this to the Backlog milestone Apr 9, 2024
@annelo-msft
Copy link
Member

@chunyu3, SCM ApiKeyCredentialPolicy has shipped in SCM. Once we can add SCM policies to Azure pipelines, I believe it will satisfy this feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Core Client This issue points to a problem in the data-plane of the library. System.ClientModel Base Core library
Projects
None yet
Development

No branches or pull requests

3 participants