File tree Expand file tree Collapse file tree 1 file changed +7
-13
lines changed
3-WebApp-multi-APIs/Controllers Expand file tree Collapse file tree 1 file changed +7
-13
lines changed Original file line number Diff line number Diff line change @@ -74,33 +74,27 @@ public async Task<IActionResult> Tenants()
74
74
75
75
public async Task < IActionResult > Blob ( )
76
76
{
77
- string message = await CreateBlob ( new TokenAcquisitionTokenCredential ( tokenAcquisition ) ) ;
78
-
79
- ViewData [ "Message" ] = message ;
80
- return View ( ) ;
81
- }
82
-
83
- private static async Task < string > CreateBlob ( TokenAcquisitionTokenCredential tokenCredential )
84
- {
77
+ string message = "Blob failed to create" ;
85
78
// replace the URL below with your storage account URL
86
79
Uri blobUri = new Uri ( "https://blobstorageazuread.blob.core.windows.net/sample-container/Blob1.txt" ) ;
87
- BlobClient blobClient = new BlobClient ( blobUri , tokenCredential ) ;
80
+ BlobClient blobClient = new BlobClient ( blobUri , new TokenAcquisitionTokenCredential ( tokenAcquisition ) ) ;
88
81
89
82
string blobContents = "Blob created by Azure AD authenticated user." ;
90
83
byte [ ] byteArray = Encoding . ASCII . GetBytes ( blobContents ) ;
91
-
92
84
using ( MemoryStream stream = new MemoryStream ( byteArray ) )
93
85
{
94
86
try
95
87
{
96
88
await blobClient . UploadAsync ( stream ) ;
89
+ message = "Blob successfully created" ;
97
90
}
98
- catch ( Exception e )
91
+ catch ( Exception )
99
92
{
100
- return ( $ "Blob failed to create. Exception: { e . Message } ") ;
101
93
}
102
94
}
103
- return "Blob successfully created" ;
95
+
96
+ ViewData [ "Message" ] = message ;
97
+ return View ( ) ;
104
98
}
105
99
106
100
[ AllowAnonymous ]
You can’t perform that action at this time.
0 commit comments