The customer is trying to use Managed Identity to access to Azure Resource by following the links below.
- Connecting from your application to resources without handling credentials
- Tutorial: Access Azure services from a .NET web app
But they face the following error after updating the code:
"HTTP Error 500.30 - ASP.NET Core app failed to start"
I also tried and faced the same issue. The customer is using 3.1 and I am using 6.0. (Without adding anything to use Managed Identity, there is no issue to deploy. Once adding something in code, it returns error message)
- Is there any step we should take which is not listed in the link above?
- Where to add the code in the link below? It is not "Program.cs"? Can anyone share the whole sample code? "https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview-for-developers?tabs=portal%2Cdotnet#accessing-a-blob-in-azure-storage"
- I am not familiar with .Net and I don't know where I can find "console.write" return in App Service. Could you please let me know? I don't get error in App Service with the below code, but once I add the code to upload file, I receive 500.30 error. I would like to check "blobClient1" is returning blob content or not, but I don't know where I can find the return(Try with Kudo, but not sure where to find).
var clientID = Environment.GetEnvironmentVariable("my client id");
var credentialOptions = new DefaultAzureCredentialOptions
{ ManagedIdentityClientId = clientID };
var credential = new DefaultAzureCredential(credentialOptions);
var blobServiceClient = new BlobServiceClient(new Uri(https://storageadfuat.blob.core.windows.net), credential);
BlobContainerClient containerClient1 = blobServiceClient.GetBlobContainerClient("blob container name");
BlobClient blobClient1 = containerClient1.GetBlobClient("blob name");
Console.Write("test", blobClient1);
Try to use Managed Identity with App Service and Azure Resources(ASP.NET). But once add the code by following the document, we receive 500.30 error message. Hopefully getting more clear sample code and manage to use the Managed Identity without any issue.
1条答案
按热度按时间bbuxkriu1#
检查以下步骤以使用
ASP.Net
中的托管标识访问Blob存储。Contibutor
角色,赠款完全访问所有资源。所以,我没有设置任何权限。Controller.cs
,否则仅将其写入Program.cs
文件。blob
。Storage Account
中,创建一个容器。Container
中,上传blob。Blob只不过是你上传的file/doc
。指令集
Storage Account
=〉Access keys
复制ConnectionString
。单击显示,将显示复制connectionstring
的图标。我的程序. cs文件
Console.WriteLine
中,在输出窗口中显示输出。而在生产(Azure应用服务)中,它不显示任何输出。本地输出
指令集