public async static Task <CloudBlockBlob> SaveAsync(HttpRequest request, CloudBlobContainer userContainer) { var principal = await StaticWebAppsAuth.GetClientPrincipalAsync(request); var blob = GetBlob(principal, userContainer); var requestBody = await new StreamReader(request.Body).ReadToEndAsync(); var user = JsonConvert.DeserializeObject <User>(requestBody); user.ClientPrincipal = principal; await SaveAsync(blob, user); return(blob); }
public async static Task <CloudBlockBlob> GetBlobAsync(HttpRequest request, CloudBlobContainer userContainer) { var principal = await StaticWebAppsAuth.GetClientPrincipalAsync(request); var blob = GetBlob(principal, userContainer); var blobExists = await blob.ExistsAsync(); if (!blobExists) { var user = new User { ClientPrincipal = principal }; await SaveAsync(blob, user); } return(blob); }