-
Notifications
You must be signed in to change notification settings - Fork 35
Description
Bug Description
When a user is not authorized to read the Azure resource for which the Private Endpoint is created then the CLI gives a cryptic error even though the Managed Private Endpoint (MPE) gets successfully created (ofc still need to be approved).
fabric-cli version
1.2.0
Python version
Python 3.12.9
Operating System
Windows
CLI Mode
Command line mode
Authentication Method
Service principal (secret)
Steps to Reproduce
On an existing Fabric workspace create a Managed Private Endpoint on a Azure Resource using the CLI with a user that is not Authorized to read the private endpoints connections of that resource.
In my scenario I was creating a MPE to an Azure Key Vault with a SPN. The SPN has full admin rights to the workspace, but has no permissions on the AKV.
WORKSPACE_NAME="ws1.workspace"
PE_KEYVAULT_RESOURCE_ID="/subscriptions/XXXX/resourceGroups/myrg/providers/Microsoft.KeyVault/vaults/mykeyvault"
fab create ${WORKSPACE_NAME}/.managedprivateendpoints/mpe1.ManagedPrivateEndpoint \
-P targetprivatelinkresourceid=${PE_KEYVAULT_RESOURCE_ID},targetsubresourcetype=vault
Creating a new Managed Private Endpoint. It may take same time (waiting until provisioned)...
x create: [UnknownError] An unexpected error occurred while processing the request
∟ Request Id: d631414d-b63e-4fcd-afbc-d739346772c8This successfully creates the MPE, although this is unclear from the error. The error is caused here:
fabric-cli/src/fabric_cli/utils/fab_cmd_mkdir_utils.py
Lines 736 to 739 in 7c7188c
| def find_mpe_connection(managed_private_endpoint, targetprivatelinkresourceid): | |
| args = Namespace() | |
| args.resource_uri = targetprivatelinkresourceid | |
| response = mpe_api.list_private_endpoints_by_azure_resource(args) |
Traceback:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\gfranssens\vscode-projects\fabric-cli\src\fabric_cli\client\fab_api_client.py", line 167, in do_request
raise FabricCLIError(
fabric_cli.core.fab_exceptions.FabricCLIError: [Forbidden] Access is forbidden. You do not have permission to access this resource
HTTP Request response 403:
{
"error": {
"code": "AuthorizationFailed",
"message": "The client 'XXX' with object id 'XXX' does not have authorization to perform action 'Microsoft.KeyVault/vaults/privateEndpointConnections/read' over scope '/subscriptions/XXX/resourceGroups/myrg/providers/Microsoft.KeyVault/vaults/mykeyvault' or the scope is invalid. If access was recently granted, please refresh your credentials."
}
}
Expected Behavior
MPE was successfully created, however the status cannot be checked.
Actual Behavior
WORKSPACE_NAME="ws1.workspace"
PE_KEYVAULT_RESOURCE_ID="/subscriptions/XXXX/resourceGroups/myrg/providers/Microsoft.KeyVault/vaults/mykeyvault"
fab create ${WORKSPACE_NAME}/.managedprivateendpoints/mpe1.ManagedPrivateEndpoint \
-P targetprivatelinkresourceid=${PE_KEYVAULT_RESOURCE_ID},targetsubresourcetype=vault
Creating a new Managed Private Endpoint. It may take same time (waiting until provisioned)...
x create: [UnknownError] An unexpected error occurred while processing the request
∟ Request Id: d631414d-b63e-4fcd-afbc-d739346772c8Additional Context
No response
Possible Solution
Error handling when making the request to check the Azure resource.