コード例 #1
0
        public IHttpActionResult Output(string id, int start = 0)
        {
            // Parse the ID
            Guid funcId;

            if (!Guid.TryParse(id, out funcId))
            {
                return(BadRequest());
            }

            // Get the invocation log
            var instance = _functionInstanceLookup.Lookup(funcId);

            if (instance == null)
            {
                return(NotFound());
            }

            if (instance.InlineOutputText != null)
            {
                return(new TextResult(instance.InlineOutputText, Request));
            }

            LocalBlobDescriptor outputBlobDescriptor = instance.OutputBlob;

            if (outputBlobDescriptor == null)
            {
                return(NotFound());
            }

            CloudBlockBlob blob = outputBlobDescriptor.GetBlockBlob(_account);

            var sb     = new StringBuilder();
            var stream = blob.OpenRead();

            try
            {
                using (var sr = new StreamReader(stream))
                {
                    stream = null;
                    string line = sr.ReadLine();
                    for (int i = 0; line != null; i++, line = sr.ReadLine())
                    {
                        if (i >= start)
                        {
                            sb.AppendLine(line);
                        }
                    }
                }
            }
            finally
            {
                if (stream != null)
                {
                    stream.Dispose();
                }
            }

            return(new TextResult(sb.ToString(), Request));
        }
コード例 #2
0
        public IHttpActionResult Blob(string path, string accountName)
        {
            if (String.IsNullOrEmpty(path) ||
                String.IsNullOrEmpty(accountName))
            {
                return(Unauthorized());
            }

            // When linking to a blob, we must resolve the account name to handle cases
            // where multiple storage accounts are being used.
            CloudStorageAccount account = AccountProvider.GetAccountByName(accountName);

            if (account == null)
            {
                return(Unauthorized());
            }

            BlobPath            parsed     = BlobPath.Parse(path);
            LocalBlobDescriptor descriptor = new LocalBlobDescriptor
            {
                ContainerName = parsed.ContainerName,
                BlobName      = parsed.BlobName
            };
            var blob = descriptor.GetBlockBlob(account);

            // Get a SAS for the next 10 mins
            string sas = blob.GetSharedAccessSignature(new SharedAccessBlobPolicy
            {
                Permissions            = SharedAccessBlobPermissions.Read,
                SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(10)
            });

            // Redirect to it
            return(Redirect(blob.Uri.AbsoluteUri + sas));
        }
コード例 #3
0
        public IHttpActionResult Blob(string path)
        {
            if (String.IsNullOrEmpty(path))
            {
                return(Unauthorized());
            }

            if (_account == null)
            {
                return(Unauthorized());
            }

            BlobPath            parsed     = BlobPath.Parse(path);
            LocalBlobDescriptor descriptor = new LocalBlobDescriptor
            {
                ContainerName = parsed.ContainerName,
                BlobName      = parsed.BlobName
            };
            var blob = descriptor.GetBlockBlob(_account);

            // Get a SAS for the next 10 mins
            string sas = blob.GetSharedAccessSignature(new SharedAccessBlobPolicy
            {
                Permissions            = SharedAccessBlobPermissions.Read,
                SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(10)
            });

            // Redirect to it
            return(Redirect(blob.Uri.AbsoluteUri + sas));
        }
コード例 #4
0
        private void DeleteParameterLogBlob(LocalBlobDescriptor blobDescriptor)
        {
            if (blobDescriptor == null)
            {
                return;
            }

            CloudBlockBlob blob = blobDescriptor.GetBlockBlob(_cloudStorageAccount);

            blob.DeleteIfExists();
        }
コード例 #5
0
        private void DeleteParameterLogBlob(LocalBlobDescriptor blobDescriptor)
        {
            if (blobDescriptor == null)
            {
                return;
            }

            CloudBlockBlob blob = blobDescriptor.GetBlockBlob(_cloudStorageAccount);
            blob.DeleteIfExists();
        }
コード例 #6
0
        public ActionResult SearchBlob(string path)
        {
            ViewBag.Path = path;

            if (String.IsNullOrEmpty(path))
            {
                return(View());
            }

            if (_account == null)
            {
                TempData["Message.Text"]  = "Account not found";
                TempData["Message.Level"] = "danger";
                return(View());
            }

            ICloudBlob blob = null;

            try
            {
                BlobPath            parsed     = BlobPath.Parse(path);
                LocalBlobDescriptor descriptor = new LocalBlobDescriptor
                {
                    ContainerName = parsed.ContainerName,
                    BlobName      = parsed.BlobName
                };

                IReadOnlyDictionary <string, CloudStorageAccount> accounts = AccountProvider.GetAccounts();
                foreach (var account in accounts.Values)
                {
                    blob = descriptor.GetBlockBlob(account);
                    if (blob.Exists())
                    {
                        break;
                    }
                    else
                    {
                        blob = null;
                    }
                }
            }
            catch (FormatException e)
            {
                TempData["Message.Text"]  = e.Message;
                TempData["Message.Level"] = "danger";
                return(View());
            }
            catch
            {
                blob = null;
            }

            if (blob == null)
            {
                TempData["Message.Text"]  = "No invocation found for: " + path;
                TempData["Message.Level"] = "warning";
                return(View());
            }

            Guid?guid;

            try
            {
                guid = BlobCausalityReader.GetParentId(blob);
            }
            catch
            {
                guid = null;
            }

            if (!guid.HasValue)
            {
                TempData["Message.Text"]  = "No invocation found for: " + path;
                TempData["Message.Level"] = "warning";
                return(View());
            }

            TempData["Message.Text"]  = "Invocation found for: " + path;
            TempData["Message.Level"] = "info";

            return(Redirect("~/#/functions/invocations/" + guid));
        }
コード例 #7
0
        public IHttpActionResult Blob(string path, string accountName)
        {
            if (String.IsNullOrEmpty(path) ||
                String.IsNullOrEmpty(accountName))
            {
                return Unauthorized();
            }

            // When linking to a blob, we must resolve the account name to handle cases
            // where multiple storage accounts are being used.
            CloudStorageAccount account = AccountProvider.GetAccountByName(accountName);
            if (account == null)
            {
                return Unauthorized();
            }

            BlobPath parsed = BlobPath.Parse(path);
            LocalBlobDescriptor descriptor = new LocalBlobDescriptor
            {
                ContainerName = parsed.ContainerName,
                BlobName = parsed.BlobName
            };
            var blob = descriptor.GetBlockBlob(account);

            // Get a SAS for the next 10 mins
            string sas = blob.GetSharedAccessSignature(new SharedAccessBlobPolicy
            {
                Permissions = SharedAccessBlobPermissions.Read,
                SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(10)
            });

            // Redirect to it
            return Redirect(blob.Uri.AbsoluteUri + sas);
        }
コード例 #8
0
        public ActionResult SearchBlob(string path)
        {
            ViewBag.Path = path;

            if (String.IsNullOrEmpty(path))
            {
                return View();
            }

            if (_account == null)
            {
                TempData["Message.Text"] = "Account not found";
                TempData["Message.Level"] = "danger";
                return View();
            }

            ICloudBlob blob = null;

            try
            {
                BlobPath parsed = BlobPath.Parse(path);
                LocalBlobDescriptor descriptor = new LocalBlobDescriptor
                {
                    ContainerName = parsed.ContainerName,
                    BlobName = parsed.BlobName
                };

                IReadOnlyDictionary<string, CloudStorageAccount> accounts = AccountProvider.GetAccounts();
                foreach (var account in accounts.Values)
                {
                    blob = descriptor.GetBlockBlob(account);
                    if (blob.Exists())
                    {
                        break;
                    }
                    else
                    {
                        blob = null;
                    }
                }
            }
            catch (FormatException e)
            {
                TempData["Message.Text"] = e.Message;
                TempData["Message.Level"] = "danger";
                return View();
            }
            catch
            {
                blob = null;
            }

            if (blob == null)
            {
                TempData["Message.Text"] = "No invocation found for: " + path;
                TempData["Message.Level"] = "warning";
                return View();
            }

            Guid? guid;

            try
            {
                guid = BlobCausalityReader.GetParentId(blob);
            }
            catch
            {
                guid = null;
            }

            if (!guid.HasValue)
            {
                TempData["Message.Text"] = "No invocation found for: " + path;
                TempData["Message.Level"] = "warning";
                return View();
            }

            TempData["Message.Text"] = "Invocation found for: " + path;
            TempData["Message.Level"] = "info";

            return Redirect("~/#/functions/invocations/" + guid);
        }
コード例 #9
0
        public IHttpActionResult Blob(string path)
        {
            if (String.IsNullOrEmpty(path))
            {
                return Unauthorized();
            }

            if (_account == null)
            {
                return Unauthorized();
            }

            BlobPath parsed = BlobPath.Parse(path);
            LocalBlobDescriptor descriptor = new LocalBlobDescriptor
            {
                ContainerName = parsed.ContainerName,
                BlobName = parsed.BlobName
            };
            var blob = descriptor.GetBlockBlob(_account);

            // Get a SAS for the next 10 mins
            string sas = blob.GetSharedAccessSignature(new SharedAccessBlobPolicy
            {
                Permissions = SharedAccessBlobPermissions.Read,
                SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(10)
            });

            // Redirect to it
            return Redirect(blob.Uri.AbsoluteUri + sas);
        }