Get Library Drive Id using Power Automate
When using Power Automate with Excel for Business actions, the drive ID for a library is automatically determined. However, if you deploy a Power Automate solution across different environments and use a library as a datasource environment variable, referencing this variable in the flow can result in an error due to an invalid drive ID.

Referencing the variable in the Power Automate flow, it will throw an error message failing to work our the drive id of the library.
When document is referenced from environment variable as source, you might encounter the following error:

The provided drive id appears to be malformed, or does not represent a valid drive.
clientRequestId: 6842e526-7afc-46a2-84f5-e40794457816
serviceRequestId: 6ffaacd1-6b2d-41d7-b3a6-963ab3e2dcbd
HTTP with Microsoft Entra ID to get Drive Id
If the action HTTP with Microsoft Entra ID is blocked in your environment you might get the following error message:

Error Example

In such cases, you can use the REST endpoint to retrieve the drive ID.
Send HTTP Request to SharePoint to get Drive Id
Using the $filter parameter does not work:
_api/v2.0/drives?filter=name%20eq%20%27data%20import%27

Instead, use the $select parameter:
_api/v2.0/drives?$select=name,id

Using Send HTTP Request to SharePoint to get Drive Id
Add the Send HTTP Request to SharePoint action to get Drive Id

Configure the properties
| Property | Value |
|---|---|
| Site Address | The SharePoint site URL |
| Method | GET |
| Uri | _api/v2.0/drives?$select=name,id |
| Headers | See Headers table below |
Headers
| Name | Value |
|---|---|
| Accept | application/json; odata=nometadata |
| Content-Type | application/json; odata=verbose |
Since the REST API does not support the $filter parameter, you need to filter the drives after retrieving them from SharePoint.
Filter Array to Get Drive ID
Use the filter array action to find the drive ID of the library:

equals(item()['name'],'Data Import')
Compose - get driveId
Use the Compose action to extract the drive ID:
outputs('Filter_array_to_get_drive_id')?['body']?[0]?['id']

List rows present in a table

If the file being created triggers the flow, reference the file using triggerBody()?['{Identifier}']
| Property | Value |
|---|---|
| Location | The SharePoint site URL |
| Document Library | outputs(‘Compose_-_get_driveId’) |
| File | triggerBody()?[’{Identifier}'] |
| Table |
The drive ID is now populated

Reference
Get drive id for Doc Library selection System Update trick to avoid locked file issue