Is it possible to test a Cloudflare App with Worker before submitting? - cloudflare-workers

After clicking “Add app” on the /apps/developer/app-creator page if I click “Save draft” I am given a message “You are not authorized to create apps with workers.”
Is there a way I can create an App that contains a worker for testing on my own domains? How do I become authorized to create an app with a worker? Is it possible to have an App that is only a worker and no client side javascript?

You can only test installing an app with a worker if you have been accepted into the beta. You can apply for the beta here: https://www.cloudflare.com/products/cloudflare-workers/#otherways
Yes, it is possible to just have workers installed on no client-side javascript. Just omit the "resources" node

Related

Firebase messaging's spawned isolate and main app - how to pass data(Web)?

According to https://firebase.flutter.dev/docs/messaging/usage/
onBackgroundMessage(...) is running on its own isolate.
How do I pass data from that isolate (which automatically spawns and runs a top level function) to the main app without using persistent storage (sqlite/files) which isn't supported on the web platform?
Flutter Web does not support isolates. You are likely looking in the wrong documentation tab. Still, what you are looking for may just not be supported yet.
Web requires you to register a JavaScript Service Worker which runs in the background.
Unfortunately we haven't yet been able to establish a proper way of communicating with the Service Worker and Flutter applications. Right now, all web background code must be executed in the JavaScript Service Worker file.
EDIT:
In order to share data between WebWorkers and the app, you can try using the awesome Drift library (formerly Moor).
https://pub.dev/packages/drift
https://drift.simonbinder.eu/web/
You can offload the database to a background thread by using Web Workers. Drift also supports shared workers, which allows you to seamlessly synchronize query-streams and updates across multiple tabs!
You should be able to communicate with the background database web worker and save your data. If correctly setup, this will in turn update your frontend.
Maybe checkout this example: https://github.com/simolus3/moor/tree/develop/extras/web_worker_example

What needs to be done for an action submission?

I am developing a google smart home action.On the Google Home App, I can set up my test action. I can use the Google Home mini turn on my devices. I used a C++ server as fulfillment (url: https://xxxx.xxx.com/google/smarthome). My server can receive and process SYNC, QUERY and EXECUTE methods.
When I running the SMARTHOME-WASHER demo. It used firebase and homegraph. I can see the washer status data in firebase database. I can see the functions in firebase, such as fakeauth, faketoken, reportstate, requestsync and smarthome. Evenytime when I turn on/off the washer. I saw reportstate and other requests.
But when I test my test action, in my test action's firebase, there are nothing. No status data, no request data.
When I use Test suite for smart home, the WASHER-DEMO is OK, my test action failed to get device list from HomeGraph.
So I want to know:
1. If firebase is necessary when I used my own fulfillment ?
2. How to report state? Request from google server to my server, or conversely?
3. When I add my test action on Google Home App, the firebase database is empty. Is this a issue?
4. What need I to do , if I want to submission my action.
I have been troubled for more than two months. Thanks for your help.
Firebase is not required. You can use any backend implementation you want. To simplify development, our codelab uses one type of implementation. If you want to use another host and database, then you can change how you handle the requests.
Report State is a command you send from your server to the Home Graph. It's proactive, meant to be sent when a device's state changes.
If you are not using Firebase for your test action, then you would not see any Firebase activity. This is fine.
To submit, you should follow this guide. Primarily, run the Test Suite and then submit your action through the Actions Console.

What will happen if ApplicationInsights InstrumentationKey gets stolen?

I am working on Angular Application and I want to add Azure Application Insights in my Angular SPA.
I have added all required configuration and Everything works perfectly fine.
Application Insights will logs all required details like PageView and custom events with the Help of InstrumentationKey.
But I have one doubt, that What will happen if ApplicationInsights InstrumentationKey gets stolen?
InstrumentationKey is exposed to external world and anyone can see it.
So my question is, Is there any problem if somebody gets this key?
what are replications if InstrumentationKey gets stolen and how can we avoid it?
I have gone through this article already -
https://blogs.msdn.microsoft.com/premier_developer/2017/12/14/alternative-way-to-protect-your-application-insights-instrumentation-key-in-javascript/
As described in the blog,
Alternatively, the most secure way would be to send data from the browser to your custom API on your server then forward to Application Insights resource with the correct instrumentation key (see diagram below).
You should validate if the data makes sense in your custom API before sending it to the Application Insights instance.
Here are a couple of more threads on the same issue:
Application Insights security and spoofing
https://github.com/MicrosoftDocs/azure-docs/issues/24287

How to handle background queries on a DB that supports a Web App

I need some help understanding how I should architect an application. Basically it has two parts.
The web app (asp mvc): A user logs into the app, records some data and logs off. The data (login info, user recorded data) is stored locally on my server. It is very simple.
The background process: I need a service to receive and send data that is connected with this web app (from #1). I have a 3rd party server that will send user login information (in real time) to my server in which I need to use to update my local DB (this is the same DB that the web app uses for login info). Secondly, I need to run a timed interval process to query the user recorded data plus perform simple logic on it and then send the outcome to this 3rd party server. These steps are all via xml docs.
I am not exactly sure how to attack this problem. I figured I could build a separate web service to do this (it would live on the same server as the web app). Or I could run some sort of webbackgrounder (https://github.com/NuGet/WebBackgrounder) task solution that is attached to my web app. Or lastly I could create a SSIS package to do this. Which route should I go? Thank you for the advice.

Run job on ASP.NET website service start in IIS

I have some method that is invoked on Application_Start. And it starts on first page request by any user.
But i have another application, dependent on that task that fires during Application_Start.
So that if IIS/website is restarted- another application cant get some data from website, until someone requests page on the running website.
Is there a way to run some task on website start; without any interaction from user side, just to start website in IIS and do the job i want?
PS more details on implementation architecture:
Website starts an instance of messaging service and starts sending messages through that service(that is located on another server). I know that it would have been better to create wcf or windows service for this kind of things, but someone wrote this website before i was included in this project. So clients(that receive messages from messaging server) do not know anything about website. Here website is just administrative panel to turn on/off some messaging features.
My Solution
Created windows service for my task. Works well, under local system account has no problems with writing to windows event logs.
Check out this "The Dangers of Implementing Recurring Background Tasks In ASP.NET"
Also you should consider installing Quartz.NET as a service, so that you can setup scheduled tasks remotely.
You can try this.
Put an entry in your code into event log
Use the windows task scheduler to create a task
Create a trigger as "Begin the task On an event"
Create the action with the job you want

Resources