Skip to content

Commit f0b5499

Browse files
committed
Fixing more security references
1 parent 14b2d85 commit f0b5499

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

articles/storage/blobs/archive-rehydrate-handle-event.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: normesta
66

77
ms.service: azure-blob-storage
88
ms.topic: how-to
9-
ms.date: 07/30/2024
9+
ms.date: 08/07/2024
1010
ms.author: normesta
1111
ms.reviewer: fryu
1212
ms.devlang: csharp
@@ -31,6 +31,8 @@ This article shows you how to use [Visual Studio 2019](https://visualstudio.micr
3131

3232
An [Azure subscription](../../guides/developer/azure-developer-guide.md#understanding-accounts-subscriptions-and-billing) is required. If you don't already have an account, [create a free one](https://azure.microsoft.com/free/dotnet/) before you begin.
3333

34+
A provisioned Microsoft Entra ID [security principal](../../role-based-access-control/overview.md#security-principal) that has been assigned the [Storage Blob Data Contributor](../../role-based-access-control/built-in-roles.md#storage-blob-data-contributor) role, scoped to the storage account, parent resource group, or subscription. See [Assign roles to your Microsoft Entra user account](storage-quickstart-blobs-dotnet.md#assign-roles-to-your-microsoft-entra-user-account).
35+
3436
## Create an Azure Function app
3537

3638
A function app is an Azure resource that serves as a container for your Azure Functions. You can use a new or existing function app to complete the steps described in this article.
@@ -61,7 +63,8 @@ To learn more about configuring your function app, see [Manage your function app
6163

6264
Next, create an Azure Function that will run when a blob is rehydrated in a particular storage account. Follow these steps to create an Azure Function in Visual Studio with C# and .NET Core:
6365

64-
1. Launch Visual Studio 2019, and create a new Azure Functions project. For details, follow the instructions described in [Create a function app project](../../azure-functions/functions-create-your-first-function-visual-studio.md#create-a-function-app-project).
66+
1. Launch Visual Studio 2019. Then, [Sign in and connect your app code to Azure using DefaultAzureCredential](storage-quickstart-blobs-dotnet.md#sign-in-and-connect-your-app-code-to-azure-using-defaultazurecredential).
67+
1. Create a new Azure Functions project. For details, follow the instructions described in [Create a function app project](../../azure-functions/functions-create-your-first-function-visual-studio.md#create-a-function-app-project).
6568
1. On the **Create a new Azure Functions application** step, select the following values:
6669
- By default, the Azure Functions runtime is set to **Azure Functions v3 (.NET Core)**. Microsoft recommends using this version of the Azure Functions runtime.
6770
- From the list of possible triggers, select **Event Grid Trigger**. For more information on why an Event Grid trigger is the recommended type of trigger for handling a Blob Storage event with an Azure Function, see [Use a function as an event handler for Event Grid events](../../event-grid/handler-functions.md).
@@ -101,9 +104,6 @@ Next, create an Azure Function that will run when a blob is rehydrated in a part
101104
// Create a unique name for the log blob.
102105
string logBlobName = string.Format("function-log-{0}.txt", DateTime.UtcNow.Ticks);
103106
104-
// Populate connection string with your Shared Key credentials.
105-
const string ConnectionString = "DefaultEndpointsProtocol=https;AccountName=<account-name>;AccountKey=<account-key>;EndpointSuffix=core.windows.net";
106-
107107
// Get data from the event.
108108
dynamic data = eventGridEvent.Data;
109109
string eventBlobUrl = Convert.ToString(data.url);
@@ -137,10 +137,12 @@ Next, create an Azure Function that will run when a blob is rehydrated in a part
137137
BlobName = logBlobName
138138
};
139139
140-
BlobClient logBlobClient = new BlobClient(ConnectionString,
141-
logBlobUriBuilder.BlobContainerName,
142-
logBlobName);
140+
TokenCredential credential = new DefaultAzureCredential();
141+
142+
string blobUri = "https://" + accountName + ".blob.core.windows.net/" + logBlobUriBuilder.BlobContainerName + "/" + logBlobName;
143143
144+
BlobClient logBlobClient = new BlobClient(new Uri(blobUri), credential);
145+
144146
byte[] byteArray = Encoding.ASCII.GetBytes(eventInfo.ToString());
145147
146148
try

0 commit comments

Comments
 (0)