%3CLINGO-SUB%20id%3D%22lingo-sub-1712566%22%20slang%3D%22en-US%22%3ENotebook%20-%20This%20request%20is%20not%20authorized%20to%20perform%20this%20operation.%20%2C%20403%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1712566%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20a%20quick%20post%20about%20this%20failure%20and%20how%20to%20fix%3A%20Error%3A%26nbsp%3B%3CSPAN%3Eorg.apache.spark.sql.AnalysisException%3A%20java.lang.RuntimeException%3A%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3EThe%20operation%20failed%3A%20'This%20request%20is%20not%20authorized%20to%20perform%20this%20operation.'%2C%20403%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EFirst%2C%20let's%20just%20add%20some%20context%20%3A%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EWhen%20you%20are%20working%20on%20synapse%20workspace%20with%20the%20managed%20identity%20you%20would%26nbsp%3Bneed%20to%20give%20Storage%20Blob%20Data%20contributor%20permission%20to%20the%20workspace%20that%20represents%20the%20managed%20identity%20permission%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fsecurity%2Fhow-to-grant-workspace-managed-identity-permissions%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fsecurity%2Fhow-to-grant-workspace-managed-identity-permissions%3C%2FA%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EMore%20information%20here%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fsecurity%2Fsynapse-workspace-managed-identity%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fsecurity%2Fsynapse-workspace-managed-identity%3C%2FA%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ESpeaking%20of%20managed%20identities%20-%3CSTRONG%3Equick%20review%3C%2FSTRONG%3E%20on%20it%3A%20%22A%20common%20challenge%20when%20building%20cloud%20applications%20is%20how%20to%20manage%20the%20credentials%20in%20your%20code%20for%20authenticating%20to%20cloud%20services.%26nbsp%3BYou%20can%20use%20the%20identity%20to%20authenticate%20to%20any%20service%20that%20supports%20Azure%20AD%20authentication%2C%20including%20Key%20Vault%2C%20without%20any%20credentials%20in%20your%20code.%22%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EMore%20here%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fmanaged-identities-azure-resources%2Foverview%3Ftoc%3D%2Fazure%2Fsynapse-analytics%2Ftoc.json%26amp%3Bbc%3D%2Fazure%2Fsynapse-analytics%2Fbreadcrumb%2Ftoc.json%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fmanaged-identities-azure-resources%2Foverview%3Ftoc%3D%2Fazure%2Fsynapse-analytics%2Ftoc.json%26amp%3Bbc%3D%2Fazure%2Fsynapse-analytics%2Fbreadcrumb%2Ftoc.json%3C%2FA%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ESo%20there%20you%20are%20with%20your%20workspace%20with%20the%20managed%20identity%20permissions%20granted%20running%20a%20notebook%20to%20create%20a%20database%20on%20Spark.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ENote%20you%20are%20the%20one%20running%20the%20%3CSTRONG%3Enotebook%20on%20Synapse%20Studio%3C%2FSTRONG%3E%20and%20you%20are%20not%20using%20any%20credentials%20as%20you%20are%20under%20Synapse%20workspace%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%25%25spark%0Aspark.sql(%22CREATE%20DATABASE%20IF%20NOT%20EXISTS%20nyctaxi%22)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CU%3E%3CSTRONG%3EIt%20fails%3A%3C%2FSTRONG%3E%3C%2FU%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CSPAN%3EError%20%3A%20org.apache.spark.sql.AnalysisException%3A%20java.lang.RuntimeException%3A%20Operation%20failed%3A%20%22This%20request%20is%20not%20authorized%20to%20perform%20this%20operation%20using%20this%20permission.%22%2C%20403%2C%20HEAD%2C%26nbsp%3B%3C%2FSPAN%3E%3CA%20title%3D%22https%3A%2F%2Fadministrators.dfs.core.windows.net%2Ffilesystemdatalake%2Ftmp%2Fhive%3Fupn%3Dfalse%26amp%3Baction%3DgetStatus%26amp%3Btimeout%3D90%22%20href%3D%22https%3A%2F%2Fadministrators.dfs.core.windows.net%2Ffilesystemdatalake%2Ftmp%2Fhive%3Fupn%3Dfalse%26amp%3Baction%3DgetStatus%26amp%3Btimeout%3D90%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2F%3CSTRONG%3EStorageAccountName.%3C%2FSTRONG%3Edfs.core.windows.net%2F%3CSTRONG%3EContainerName%3C%2FSTRONG%3E%2Ftmp%2Fhive%3Fupn%3Dfalse%26amp%3Baction%3DgetStatus%26amp%3Btimeout%3D90%3C%2FA%3E%3CSPAN%3E%3B%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CU%3E%3CSTRONG%3ESolution%3A%3C%2FSTRONG%3E%3C%2FU%3E%3C%2FDIV%3E%0A%3CDIV%3EAdd%20the%20RBAC%20Storage%20Blob%26nbsp%3BData%20Contributor%20to%20the%20user%20that%20is%20running%20the%20notebook%2C%20or%20your%20user.%3C%2FDIV%3E%0A%3CDIV%3ESteps%20here%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fsecurity%2Fhow-to-grant-workspace-managed-identity-permissions%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fsecurity%2Fhow-to-grant-workspace-managed-identity-permissions%3C%2FA%3E%26nbsp%3B(Grant%20permissions%20to%20managed%20identity%20after%20workspace%20creation)%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3EIn%20this%20case%2C%20the%20script%20is%20running%20under%20the%20user%20that%20is%20executing%20the%20notebook.%20So%20this%20user%20needs%20permission%20as%20well.%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3EThat%20is%20it!%3C%2FDIV%3E%0A%3CDIV%3ELiliam%20Uk%20Engineer.%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1712566%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20a%20quick%20post%20about%20this%20failure%20and%20how%20to%20fix%3A%20Error%3A%26nbsp%3B%3CSPAN%3Eorg.apache.spark.sql.AnalysisException%3A%20java.lang.RuntimeException%3A%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3EThe%20operation%20failed%3A%20'This%20request%20is%20not%20authorized%20to%20perform%20this%20operation.'%2C%20403%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1712566%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESynapse%20Administration%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESynapse%20Spark%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESynapse%20Support%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

This a quick post about this failure and how to fix: Error: org.apache.spark.sql.AnalysisException: java.lang.RuntimeException:
The operation failed: 'This request is not authorized to perform this operation.', 403

 

First, let's just add some context : 

 

When you are working on synapse workspace with the managed identity you would need to give Storage Blob Data contributor permission to the workspace that represents the managed identity permission:

https://docs.microsoft.com/en-us/azure/synapse-analytics/security/how-to-grant-workspace-managed-ide...

More information here: https://docs.microsoft.com/en-us/azure/synapse-analytics/security/synapse-workspace-managed-identity

 

Speaking of managed identities -quick review on it: "A common challenge when building cloud applications is how to manage the credentials in your code for authenticating to cloud services. You can use the identity to authenticate to any service that supports Azure AD authentication, including Key Vault, without any credentials in your code."

More here: https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview?...

 

So there you are with your workspace with the managed identity permissions granted running a notebook to create a database on Spark.

Note you are the one running the notebook on Synapse Studio and you are not using any credentials as you are under Synapse workspace:

 

 

 

 

 

%%spark
spark.sql("CREATE DATABASE IF NOT EXISTS nyctaxi")

 

 

 

 

 

It fails:
Error : org.apache.spark.sql.AnalysisException: java.lang.RuntimeException: Operation failed: "This request is not authorized to perform this operation using this permission.", 403, HEAD, https://StorageAccountName.dfs.core.windows.net/ContainerName/tmp/hive?upn=false&action=getStatus&ti...;
Solution:
Add the RBAC Storage Blob Data Contributor to the user that is running the notebook, or your user.
Steps here: https://docs.microsoft.com/en-us/azure/synapse-analytics/security/how-to-grant-workspace-managed-ide... (Grant permissions to managed identity after workspace creation)
 
In this case, the script is running under the user that is executing the notebook. So this user needs permission as well.
 
 
That is it!
Liliam Uk Engineer.