opomba,
Dostop do te strani zahteva pooblastilo. Poskusite se vpisati alispremeniti imenike.
Dostop do te strani zahteva pooblastilo. Poskusite lahko spremeniti imenike.
Apps use the Azure Identity crate to authenticate to Microsoft Entra ID and access Azure services. This article summarizes recommended authentication approaches for apps running on Azure, hosted on-premises, or in local development.
Recommended token-based authentication
The recommended approach is to have your apps use token-based authentication, rather than connection strings or keys, when authenticating to Azure resources. The azure_identity crate provides token-based authentication and enables apps to seamlessly authenticate to Azure resources whether the app is in local development, deployed to Azure, or deployed to an on-premises server.
The specific type of token-based authentication an app should use to authenticate to Azure resources depends on where the app is running.
| Environment | Authentication |
|---|---|
| Local | When a developer runs an app during local development - The app can authenticate to Azure using the developer's local credentials. These options are provided in more detail in the crates.io: Authenticate with development tools. |
| Azure | When an app is hosted on Azure - The app should authenticate to Azure resources using a managed identity. This option is discussed in more detail in the crates.io documentation: Authenticate Azure-hosted applications. |
| On-premises | When an app is hosted and deployed on-premises - The app should authenticate to Azure resources using an application service principal. This option is discussed in the crates.io documentation: Authenticate service principals. |
Advantages of token-based authentication
When building apps for Azure, we strongly recommend using token-based authentication instead of secrets like connection strings or keys.
| Token-based authentication | Secrets (connection strings and keys) |
|---|---|
| Principle of least privilege, establish the specific permissions needed by the app on the Azure resource. | A connection string or key grants full rights to the Azure resource. |
| There's no application secret to store. | Must store and rotate secrets in app setting or environment variable. |
| The Azure Identity library manages tokens for you behind the scenes. This makes using token-based authentication as easy to use as a connection string. | Secrets aren't managed. |
Use of connection strings should be limited to initial proof of concept apps or development prototypes that don't access production or sensitive data. Otherwise, the token-based authentication classes available in the Azure Identity library should always be preferred when authenticating to Azure resources.
Authentication for Azure-hosted apps
When you host your app on Azure, it can use managed identities to authenticate to Azure resources without needing to manage any credentials. There are two types of managed identities: user-assigned and system-assigned.
Use a user-assigned managed identity
You create a user-assigned managed identity as a standalone Azure resource. You can assign it to one or more Azure resources, allowing those resources to share the same identity and permissions. To authenticate by using a user-assigned managed identity, create the identity, assign it to your Azure resource, and then configure your app to use this identity for authentication by specifying its client ID.
Use a system-assigned managed identity
You enable a system-assigned managed identity directly on an Azure resource. The identity is tied to the lifecycle of that resource and is automatically deleted when the resource is deleted. To authenticate by using a system-assigned managed identity, enable the identity on your Azure resource and then configure your app to use this identity for authentication.
Authentication during local development
When an application is run on a developer's workstation during local development, the local environment must still authenticate to any Azure services used by the app.
During local development, authenticate to Azure resources by using your developer credentials or a service principal.
Use developer credentials
Use your own Azure credentials to authenticate to Azure resources during local development. Typically, use a development tool, such as Azure CLI, which can provide your app with the necessary tokens to access Azure services.
Use a service principal
Use a service principal only when you need to test authentication with an application identity during local development.
Authentication for apps hosted on-premises
For apps hosted on-premises, use a service principal to authenticate to Azure resources. This method involves creating a service principal in Microsoft Entra ID, assigning it the necessary permissions, and configuring your app to use its credentials.
Additional resources
- Additional authentication methods — client certificates, workload identity, Azure Pipelines, and federated identity credentials
- Azure Identity crate on crates.io
- Azure Identity API reference on docs.rs
- Azure SDK crates on Crates.io - List of available Azure SDK crates
- Azure SDK design guidelines - Design principles and patterns
- Azure SDK for Rust GitHub repository - Issues and source code
- Cargo documentation - Complete Cargo reference