-
Notifications
You must be signed in to change notification settings - Fork 198
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
auth: Support azure-pipelines
for --federated-credential-provider
#4343
auth: Support azure-pipelines
for --federated-credential-provider
#4343
Conversation
6d6aec1
to
f22a1ca
Compare
0a257b5
to
2ee5a78
Compare
cd2961b
to
5a7e72d
Compare
5a7e72d
to
f1d9cdc
Compare
62a7919
to
1a25a0e
Compare
azure-pipelines
for --federated-credential-provider
This change adds `azure-pipelines` as a supported value for the `--federated-credential-provider` switch of `azd auth login`. This provider can be used to do OIDC based login within the context of a job running in Azure Pipelines. When using this provider, `azd` uses the `AzurePipelinesCredential` type to manage the OIDC dance. In addition to the client and tenant id of the service principal you plan to authenticate with, we also need the "service connection id" (this is the ID of the object created in Azure Pipelines that contains the connection information) and the system access token which is the security token for the running build (it's what is used to authenticate to the OIDC endpoint that is being run inside the pipeline which we use to fetch the federated credential). The client and tenant ids can be provided on the command line, via the existing `--client-id` and `--tenant-id` switches, or, when `azure-pipelines` is the `federated-credential-provider`, they can be read from the `AZURESUBSCRIPTION_CLIENT_ID` and `AZURESUBSCRIPTION_TEANT_ID` system environment varaibles. The service connection ID and acceess token are read from the `AZURESUBSCRIPTION_SERVICE_CONNECTION_ID` and `SYSTEM_ACCESSTOKEN` environment variaibles. These system environment variables correspond to what the `AzureCLI@2` sets when passing the `azureSubscription` parameter (after translating the service connection name to a service connection ID, which is handy) allowing something like this to work: ```yaml - task: AzureCLI@2 inputs: azureSubscription: azconnection scriptType: bash scriptLocation: inlineScript inlineScript: | azd auth login --federated-credential-provider "azure-pipelines" azd up ``` Note that while the AzureCLI task is used above, it's only used for setting these environment variables and doing the service connection name to id translation. You could do something like the following instead: ```yaml - bash: | azd auth login --federated-credential-provider "azure-pipelines" azd up env: AZURE_SUBSCRIPTION_CLIENT_ID: "Your Client ID" AZURE_SUBSCRIPTION_TENANT_ID: "Your Tenant ID" AZURE_SUBSCRIPTION_SERVICE_CONNECTION_ID: "Your Service Connection ID" SYSTEM_ACCESSTOKEN: $(System.AccessToken) ``` And things will work as well. This can be useful in cases where you can use the `AzureCLI@2` task directly. We can consider writing our own task as some point as well. Contributes To Azure#4341
1a25a0e
to
0c1313e
Compare
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash:
pwsh:
WindowsPowerShell install
MSI install
Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Now that `azd` supports OIDC in Azure Pipelines via Azure#4343, let's use it in the `build-cli` leg of CI. Since we now use OIDC, we can also migrate to the TME environment for the resources created during our tests, by using the new `azd-service-connection` service connection.
Now that `azd` supports OIDC in Azure Pipelines via Azure#4343, let's use it in the `build-cli` leg of CI. Since we now use OIDC, we can also migrate to the TME environment for the resources created during our tests, by using the new `azd-service-connection` service connection. Contributes To Azure#4341
Now that `azd` supports OIDC in Azure Pipelines via Azure#4343, let's use it in the `build-cli` leg of CI. Since we now use OIDC, we can also migrate to the TME environment for the resources created during our tests, by using the new `azd-service-connection` service connection. Contributes To Azure#4341
This change adds
azure-pipelines
as a supported value for the--federated-credential-provider
switch ofazd auth login
. This provider can be used to do OIDC based login within the context of a job running in Azure Pipelines.When using this provider,
azd
uses theAzurePipelinesCredential
type to manage the OIDC dance. In addition to the client and tenant id of the service principal you plan to authenticate with, we also need the "service connection id" (this is the ID of the object created in Azure Pipelines that contains the connection information) and the system access token which is the security token for the running build (it's what is used to authenticate to the OIDC endpoint that is being run inside the pipeline which we use to fetch the federated credential). The client and tenant ids can be provided on the command line, via the existing--client-id
and--tenant-id
switches, or, whenazure-pipelines
is thefederated-credential-provider
, they can be read from theAZURESUBSCRIPTION_CLIENT_ID
andAZURESUBSCRIPTION_TEANT_ID
system environment varaibles. The service connection ID and acceess token are read from theAZURESUBSCRIPTION_SERVICE_CONNECTION_ID
andSYSTEM_ACCESSTOKEN
environment variaibles.These system environment variables correspond to what the
AzureCLI@2
sets when passing theazureSubscription
parameter (after translating the service connection name to a service connection ID, which is handy) allowing something like this to work:Note that while the AzureCLI task is used above, it's only used for setting these environment variables and doing the service connection name to id translation. You could do something like the following instead:
And things will work as well. This can be useful in cases where you can use the
AzureCLI@2
task directly.We can consider writing our own task as some point as well.
Contributes To #4341