Embed/REST API for azure analytics - c#

Is there an API available to pull telemetry/insights data for websites from the azure portal, so I can display that data on my 3rd party site? I'm looking for something similar to Google Analytics embed API.

I do not think there is a specific API for Azure Web Apps analytics (the new name, as I found out today). However, you can configure your web site to log to Azure storage - either table storage or blob storage, and then use the regular storage REST APIs (or use the storage client classes from one of the Azure SDKs). You can do this configuration when you enable logging in the Azure portal. The choices for log destination are File (i.e. the local filesystem - these can then be pulled by FTP) or Table or Blob (these can then be accessed by the storage REST API).
It is summarised here:
http://azure.microsoft.com/en-us/documentation/articles/web-sites-enable-diagnostic-log/
Note: In that link they describe how you can stream logs for real time log viewing (using PowerShell or the Azure command line tools). I think this is intended for debugging purposes rather than embedding in an application, but it might help you...
An alternative approach (disclaimer: I never tried this) is to integrate NewRelic into your application and then use their REST API to extract their monitoring information:
https://docs.newrelic.com/docs/apm/apis/requirements/extracting-metric-data

Related

Uploading Image from WebAPi [ Azure Mobile APP] to Folder in Azure Web App

I have created an Azure Mobile App & and Azure Web App. What I need to do is upload image from mobile using webapi endpoint of the Azure Mobile APP and Upload it to a folder inside my Azure Web App.
I am able to get the image in my api using HTTpContext so I can save it inside a folder in the webapi itself but it is not what I need. I have no idea how to save it to folder inside my Web App. But API and WebAPP have same resource group.
Please point me in the right direction as to how it can be done.
I am able to get the image in my api using HTTpContext so I can save it inside a folder in the webapi itself but it is not what I need. I have no idea how to save it to folder inside my Web App. But API and WebAPP have same resource group.
As Azure-Web-App-sandbox states about File System Restrictions/Considerations:
Every Azure Web App has a home directory (d:\home) stored/backed by Azure Storage. This network share is where applications store their content. This directory is available for the sandbox with read/write access.
So for a specific Azure Web App, the Azure Web App content is stored on Azure Storage and is shared among multiple instances. But it does not shared between different web apps.
For uploading file(s) from your mobile app to azure web app, you could leverage the VFS API under KUDU REST API as follows:
PUT /api/vfs/{path}
//Puts a file at path.
PUT /api/vfs/{path}/
//Creates a directory at path. The path can be nested, e.g. `folder1/folder2`.
Note: You need to use the basic authentication. Detailed code snippet, you could follow here.
Additionally, as rahicks pointed out that you could directly upload your resources into a central data storage, then they would be accessed in your multiple applications. And you could leverage Azure Storage Client Library for .NET and directly upload images to your blob storage. Also, you could leverage the storage client library in your azure web app for reading/writing your resources. Detailed tutorials, you could follow here. Moreover, you could use Azure Storage Explorer to manage your storage resources.
///... check rest of request
///... define image path #"image/img1"
///... persist entity with image path
path = Server.MapPath(imagePath);
if(!System.IO.File.Exists(path))
file.SaveAs(Server.MapPath(path));
If you need more help here is a step by step. It's a bit old, but should do the trick.
http://www.c-sharpcorner.com/blogs/how-to-upload-image-and-save-image-in-project-folder-in-mvc1
Update:
Since you need to share between servers it would be best to set up a blob storage account for this. Here is a walkthrough on that:
https://www.codeproject.com/articles/490178/how-to-use-azure-blob-storage-with-azure-web-sites

Moving an asp.net web forms site on azure without coding it again to use azure blob storage

I have a asp.net web forms web site that uses many files from server disk, accept uploads, processing files on the server. All the files stored in the web server's disks.
I would like to move my site to azure web sites. But to do that i think we need to update site code to keep files in azure blobs and process from it. Right now we are not able to that. So can i move my web site to azure without using azure blobs? Is there any way i can move all my site and files to azure, keep and publish on azure but not on azure blobs?
Using Virtual Machine is not an option to us right now.
Every Azure App Service/Website comes with persisted storage, which is technically an Azure storage blob mapped to the local file system. However, your code need not be aware of that. The details are described to the File System section here.
If you can configure paths for your server files, this persisted storage should suffice.

Asp.NET MVC and Azure storage

We are currently working on moving our Asp.NET MVC app from a shared hosting provider to Azure. Our users can upload files such as images and documents to our server and we store these files under app-url/content/data which works pretty well.
Question:
Is it safe to keep doing the same thing and uploading files under app-url/content/data ? I've read about the Azure blob storage but we would like minimize the amount of work required to move to Azure (this is definitely something we could do in the coming months)
Azure provides a number of storage options such as Azure SQL, DocumentDB, Azure Blob storage and more, you can use anyone. If your application is just storing the images, Azure Blob storage is the best option.
Is it safe to keep doing the same thing and uploading files under app-url/content/data ?
Definitely, the security is not concerns to Azure Customers. It is Microsoft's concern you can learn about Azure security from here.
we would like minimize the amount of work required to move to Azure.
This depends upon your application's back-end storage and resource management. If you are setting a new Azure VM for running your application, it might take long. If you are about to use Azure Web Apps (Recommended), it will minimize your migration workload as you may be already familiar with.

How can Azure MobileServiceClient be used to upload files?

I am developing a mobile client on Xamarin with a server on Azure Mobile Service.
I use Microsoft.WindowsAzure.MobileServices.MobileServiceClient to send application/json messages to the server.
Now I need to upload files too.
How can I use form/multipart with MobileServiceClient?
TIA
Azure Mobile Services only use data in tables, no files at all. Therefore, the MobileServicesClient is only built to exchange with table data.
You might use other Azure services like Blob Storage to put files there.
If you only need to store really small images, you can put them into the database as textdata, but this has many limitations. Chris Risner has a tutorial on his Blog.

What is the best practice to consume Azure table storage in a windows store app?

I'm using PRISM framework to develop my App, there is no Patterns and practice guidance available on consuming Azure table with Windows store app?
What is the best practice to consume Azure table storage in a windows store app?
App calling WCF REST service which then talks to Azure table through Azure SDK
App calling Azure table storage REST service
App calling Azure mobile service which then talks to Azure table through data script
App consuming Azure table storage through Azure SDK
Any other option?
I don't think there's any guidance available on the best practices for consuming Azure Table Storage with Windows Store App.
Given your 4 options above, I would not recommend using #2 and #4 as is for one reason - In order for you to use any of these options, you would need to include your storage credentials (account name/account key) in your application itself which I think is a big security risk.
There's one other way by which you can use #2 and #4 and that's by using Shared Access Signature (SAS) functionality. Essentially you create SAS tokens using some kind of server side code (WCF/Mobile Service/Web API etc.) and provide that SAS token to your client application. Then you can use #2 or #4 approach.
The advantage with this approach to me is that your server-side component is really light weight as all it is doing is creating SAS tokens and your Windows 8 application is directly talking with storage service without the need of an intermediary. Given that Windows Azure Table Storage now supports JSON, the data transferred between your app and storage will be very minimal (compared to ATOMPUB XML format which was really bulky).

Categories

Resources