# EntraIdApi Methods

- Package: [Aspire.Hosting.Azure.EntraId](/reference/api/csharp/aspire.hosting.azure.entraid.md)
- Type: [EntraIdApi](/reference/api/csharp/aspire.hosting.azure.entraid/entraidapi.md)
- Kind: `Methods`
- Members: `1`

Identifies an API that is not modeled as an Aspire resource, such as Microsoft Graph, by its well-known application ID.

<a id="fromapplicationid"></a>
<a id="fromapplicationid-string-string-string-string"></a>

## FromApplicationId(string, string, string, string?)

- Name: `FromApplicationId(string, string, string, string?)`
- Modifiers: `static`
- Returns: [EntraIdApi](/reference/api/csharp/aspire.hosting.azure.entraid/entraidapi.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/2d325b13709752ba6d9a943635c5e2940a2530c0/src/Aspire.Hosting.Azure.EntraId/EntraIdApi.cs#L174-L195)

Identifies another API, whose service principal must exist in the tenant, by its application ID.

```csharp
public sealed class EntraIdApi
{
    public static EntraIdApi FromApplicationId(
        string displayName,
        string applicationId,
        string resourceUri,
        string? baseUrl = null)
    {
        // ...
    }
}
```

## Parameters

- `displayName` (`string`)
  A name for the API used in diagnostics and as the name of its `DownstreamApis` entry (its letters and digits).
- `applicationId` (`string`)
  The API's application (client) ID, as a GUID.
- `resourceUri` (`string`)
  The API's application ID URI, the prefix of its scopes in token requests, such as `api://contoso-orders` or `https://contoso.onmicrosoft.com/orders`. It is shown as "Application ID URI" on the API's registration. It is not derived from `applicationId` because an API can use any URI.
- `baseUrl` (`string?`) `optional`
  The API's root URL, such as `https://graph.microsoft.us`, which Aspire adds to the `DownstreamApis` entry as `BaseUrl`. When `null`, no `BaseUrl` is set and the caller must supply the address itself.

## Returns

[EntraIdApi](/reference/api/csharp/aspire.hosting.azure.entraid/entraidapi.md) -- The API. Its permissions must be requested with explicit IDs.

## Exceptions

- `ArgumentException` -- `applicationId` is not a GUID, `resourceUri` is not a valid application ID URI, or `baseUrl` is not an absolute HTTP or HTTPS URL.
