How can I expose my Azure Table storage data as JSON? - c#

I am new to Azure and trying to get the data from Azure table storage. I am able to read it using c# code and do all CRUD operations. But I am looking for built in REST API from azure storage? Is it available?
Below article says that we need to write our own service and deploy.
https://blog.kloud.com.au/2016/06/09/using-microsoft-azure-table-service-rest-api-to-collect-data-samples
But this require me to have IIS ?? or do I have to write app service in c#??
I want JSON because I want to read it from android app but I do not want to use azure android SDK. I want pure REST API
This article http://chrisrisner.com/Mobile-Services-and-Windows-Azure-Storage is close but it's recommending me create SQL Azure database!! so I am confused.

Based on your requirement, I would recommend you go Shared Access Signature (SAS) route. In short, a SAS is a time-limited/permission-based access to your Azure Storage resources. This removes the need for you to store the storage access key in your application as it poses a major security risk and some other issues.
To read more about SAS, please see this link: https://azure.microsoft.com/en-in/documentation/articles/storage-dotnet-shared-access-signature-part-1. This should give you some idea about what is possible with SAS.
Here's how it would work. There will be a server component which will know about the account key. Your app would request this server component to generate and return the SAS URL. It is recommended that you only grant the necessary permissions and only for the required duration in the SAS.
Once your app has the SAS URL, they can simply make HTTP requests directly to Azure Storage by using this SAS URL and get the data back directly from Azure Tables in JSON format. For example, if you want to fetch entities from a table you would make Query Entities REST API call: https://msdn.microsoft.com/en-us/library/azure/dd179421.aspx.
To learn more about SAS, please see this link as well: https://msdn.microsoft.com/en-us/library/azure/ee395415.aspx.

I do not want to store storage key inside android app.
This app is just showing the temperature from a azure storage which is real time pushed by event hub from device to table storage
Regardless your requirement is simply, and it is correct that we don't recommend to expose your storage key in clients. However, to provide table storage entities to your clients, we still need a backend server.
If you have an Azure Mobile Apps server as a backend server for your devices, you can directly integrate Azure Storage SDK in custom APIs to provide table storage entities for your devices. Refer to https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-dotnet-backend-how-to-use-server-sdk/#how-to-define-a-custom-api-controller for more.
If you don't have an Azure Mobile Apps, you can leverage Auzre Function Apps for you simple requirement, whose environment has automatically added the assembly Microsoft.WindowsAzure.Storage, please refer to https://azure.microsoft.com/en-us/documentation/articles/functions-reference-csharp/ for more.

Related

How to create a file or upload a file to Azure Data Lake Storage Gen2

I have created a Azure Data Lake Storage Gen2 account through azure portal. How can I create a file in that account through c# code. I googled a lot but didn't find any samples.
Update 1:
In order to call REST api, I tried to generate token using below code but getting issue.Could you please post some sample code or correct me if anything goes wrong.
Issue:
AADSTS90002: Tenant 'token' not found. This may happen if there are no
active subscriptions for the tenant. Check with your subscription
administrator.
Update 2:
I have used below code aswell to create file but it is throwing error.
For now no SDK is supported for ADSL gen2, check the document:Known issues with Azure Data Lake Storage Gen2.
Blob storage APIs are disabled to prevent feature operability issues that could arise because Blob Storage APIs aren't yet interoperable with Azure Data Lake Gen2 APIs.
However you still could use the ADSL REST API, do the create,delete operation.
Update: For now, in the github there is a unofficial sdk, may be you could have a try. It's implemented with the REST API, here is the github link:AzureDataLakeGen2-SDK.
There is a Rest API to CRUD operations for Azure Data Lage Storage Gen2. You can implement them in your code like any other API call. You may Use HttpClient and read the response etc.
Azure Data Lage Storage Gen2 Rest documentation:
https://learn.microsoft.com/en-us/rest/api/storageservices/data-lake-storage-gen2

Use Azure Storage for Multi-Tenant Application Logging and Tracing

We are working on a multi-tenant web application (ASP.NET, MVC, C#) which is going to host in Azure App Service. Each tenant will have separate DB and separate Azure Storage account for store files.
I have gone through MSDN article on Enabling Storage Logging. But according to it Application Logging on Blob Storage cannot keep per Tenant.
My question is,
Is there a way to configure multiple Blob storages and write log
entries to them?
If not, Is there any way to handle this using code?
Is there any logging framework (Nlog, Log4Net etc) support for multiple azure storage accounts?
If you want to log into storages linked to tenants you would probably have to handle it in code. E.g. keep track of tenant id in the requests and being able to resolve storage wrapper with appropriate connection string.
I would recommend you to take a look at Azure OMS Log Analytics. Just create log records with tenantId and push it to OMS. All your logs will be at the same place and you'll be able to query logs by tenant (where tenantId=123) or by type e.g. "error".
Documentation

Access to Azure File Storage via VNet

I faced with follow problem hope I can find the way for solving with your help.
I created follow Azure resources:
WebApp Service (Asp.Net Core web application)
FileStorage
VirtualNetwork
All resources created in one resources group. I trying to upload file from my WebApp to File storage via VNet (I need to secure storage so it must be unaccessable from outside internet).
Virtual Network have subnet, wich have setup a Microsoft.Storage - Service endpoints. This sub net is included In Storage firewall settings.
For work with Azure storage I use Microsoft.WindowsAzure.Storage package.
When I trying to get access to storage from webapp I get 403 error.
For access I use 'primary file service endpoint' - https://myaccount.file.core.windows.net/
What I have missed ?
Thnx for any advice !
Azure File shares can’t be accessed from Azure App Service web apps. Refer this feedback item where the feature was declined.

Where do I store media in an Azure Web App with C# ASP.NET

I am creating a C# ASP.NET app (using Visual Studio), which I'm hosting on Microsoft Azure. Currently, I have a folder in the solution named "Content", in which I store some media. For example, there a logo that is placed on the website.
The purpose of the web app is to generate a document that a user can download after entering some data. To generate this document, I also need to use some media (mainly images). There can be quite a lot of such images!
Where should I store these images? I currently have them in this "Content" folder as well (in seperate sub folders for each user), but I noticed on Azure there is also a tab called "Storage". I have tried to use this service for a bit, but I don't really understand its purpose. Would it be advisable to use this for storing the media, and then retrieving them with the web app when necessary, or should I leave them on the web app server? What is considered Good Practice?
Thanks in advance for any help
As a starting point, using Blob storage (see Azure Storage Documentation) would be significantly better than file storage on a single webserver - its cheaper and more scalable (pricing tiers for Application server storage will be expensive, you'd have have to duplicate files or have a multi-server directory in a load-balanced environment). The basic design is the application will use an SDK to retrieve the bits and then stream it back to the web browser or other client.
If you anticipate many users downloading the same file, and network performance matters, consider using a Content Delivery Network
You should store it in an Azure Storage Account and reference it using the SDK, after generating the document, you can use Shared Access Signature to give the user access and you can limit the access to read or write for a specific time.
If you will generate videos then you can serve it through Azure Media Services

Technologies for making a web service that interacts with a REST API?

My Google-foo is failing me here... most likely a terminology thing.
Basically, I'm making a desktop (and likely mobile) application that connects to a REST API that returns JSON. I've created a C# class library that handles the the data querying in my local project however this would expose my API key if I were to publish it.
I would like to know what are the appropriate options for simply running a small service in Azure that takes a web request, queries the API and passes the JSON response back. Something lightweight, decently scalable.
Is this something a web role or worker role is good for? Is this something I really should learn Node.js for?
I asked a similar question a few years back: Keeping a secret key secret with Amazon Web Services
One reasonable solution is to build a simple service that returns the headers and url to use when communicating with the authenticated service. Your API key remains secret because it only lives in your service, but the clients can leverage the API key by getting the encrypted request from your service and then making the request for the actual work.
I haven't personally looked into the Azure API App Service, but a brief browse of the main website suggests that it, too, may be relevant to your interests. :)
Check out Azure Mobile Apps. Azure Mobile Apps is a "backend as a service" platform. With Mobile Apps you can easily store information into a SQL Database and expose custom API methods. It is a great place to start and has SDKs for connecting iOS, Andriod, Xamarin, and HTML apps.
As for security, the Mobile service has options to protect the data from allow anonymous access to requiring each user to authenticate.

Categories