How to communicate from Azure webjob to Azure webapp? - c#

I'm running an Azure webjob alongside an Azure webapp. The job runs periodically and the result of the job is needed in the webapp. How do I get the result there?
I tried with a WCF netNamedPipeBinding but since there are no startup tasks for Azure webapps I cannot add a net.pipe binding to the IIS website nor can I enable the net.pipe protocol.
I have it working now with a basicHttpBinding but this binding is exposed to the entire internet which I absolutely do not want. I simply want machine-local communication between a webjob and webapp running on the same machine.
CORRECTION: I thought I had it working on Azure but that is not the case. When running on Azure I get an error from the webjob: An attempt was made to access a socket in a way forbidden by its access permissions 127.0.0.1:80 (using basicHttpBinding). Probably the webapp has an internal port number I don't know.

You have a few options:
Use the file system to pass messages
Use Azure Storage Queues to pass messages between the two
Use Azure Service Bus Queue to pass messages
Use any shared storage (database, Azure Storage, etc) to pass messages
The benefit of all these approaches is that it makes your message passing async and thus more resilient to one of the two services (web app or web job) going down for some time.

You can use the file-system to communicate between the WebJob and the Websites.
It is shared between them and between all of your instances.
Simply write a file from the WebJob and use a file system watcher in your webapp to recognize when a file is created or changed.
Note you cannot communicate through localhost in Azure Websites (or WebJobs) and cannot listen on a port that is not 80/443.

You can use azure service bus queue, then point your service (web app) to consume messages from queue.

The closest answer is to set WEBSITE_DISABLE_SCM_SEPARATION=true in App Settings. This will enable WebApp and SCM processes work in same sandbox. Unfortunately this option is deprecated by Azure and no longer supported. Thanks all for attempting the answer. More information can be found here.

Related

Theory: Azure Websockets

Is it possible to consume an external (to Azure) API that requires you to establish a wss connection to receive notifications of changes in some kind of Azure container (Kubernetes/Durable Function)?
Or do I need to run a Virtual Machine with a background service keeping the socket alive until it's got no more data to send (hours). No UI.
https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-overview?tabs=csharp
Durable functions look promising but I'm unsure if these will cover my requirements.
Any advice welcomed.
Yes, you should be able to use WebSocket connections to services deployed on Kubernetes. And also the other way around where services in Kubernetes is WebSocket clients with connections to external services.
I haven't tested, but Azure Web App supports Web Socket. As you can host Azure Functions in the same App Service which is running your web app, I think it's possible to support web sockets on your functions with durable function.
Another point that leads me to think this, is the native support of Azure Functions to SignalR Service, which runs on Web Socket too.

IIS hosted service accessing Azure Queue storage

We are currently in this inbetween stage of hosting services on a VM in IIS and migrating some of them to Azure.
I have two services, Service A - which inserts items into an Azure Queue Storage and Service B - which is a Console app which uses the Web Job libraries and consumes messages from the Queue.
As far as I understand the Service B (consumer) must be hosted in Azure and be given access to the Azure Queue, but can Service A (producer) that inserts messages into the Queue be hosted in IIS? Is that possible?
I can currently use the local storage emulator to reproduce this behaviour locally, but it's not really something we can use in production. Ideally I'd like the means to connect to the Queue storage remotely, I'm just not sure if it is possible.
The reason why I want to host the Service A in IIS is that it communicates with other IIS hosted services and uses logging to a file, which Azure doesn't support very well and Azure logging would be very different to how we currently monitor/log events.
Any app using the Azure Storage SDK can connect to and work with Storage Queues. The app could be hosted anywhere; in Azure App Service, in Azure VM, On-premises VM, in AWS VM, anywhere.
can Service A (producer) that inserts messages into the Queue be hosted in IIS?
Like Chris said, any app on the internet can insert messages into the Queue if it knows the Storage value and key, if you do not want to let app knows the Azure Storage key but also want to insert messages, please consider use SAS, this is another story. Anyway, please do not worry about this.

Using Azure Service Fabric Reliable Actors across different systems

When using Service Fabric Reliable Actors, is it possible for an actor client in one system (for example, on a local deployment) to communicate with an actor server in a different system (for example, on an Azure cloud deployment)? If so, how can this be configured? If not, what Azure functionality could I use to achieve this instead? The linked overview gives code examples for the client and server, but not any of the necessary configuration steps.
For communicating from a client to an actor running in a cluster, you need to have direct connectivity today - for example the Azure Load Balancer can't be in the way. To configure which cluster to connect to, create a ServicePartitionResolver with the FabricClientSettings, SecurityCredentials, and Endpoints matching the cluster, and then use ServicePartitionResolver.SetDefault (https://msdn.microsoft.com/en-us/library/microsoft.servicefabric.services.client.servicepartitionresolver.aspx)

Azure: Best way to check for a new json file on external server

I'm writting a mobile application which should receive a notification if a JSON file on an external server is changed.
I would love to do this in Azure by checking every 20 seconds if the file has changed (and if it's the case I send a push-notification).
What's the best way to do this in Azure?
Scheduling options in Azure
Azure Cloud Service
Azure Scheduler - for heavier workloads invoked on other services
Azure Websites WebJobs - for lightweight workloads
Azure Mobile Services Scheduled Job
For your situation probably use Azure Mobile Services to periodically schedule a job and use Mobile Services to send push notifications

Has anyone created an FTP adapter for the Windows Azure Service Bus Brokered Messaging service?

Let us say that I have an FTP server getting XML files sent each day, and that I want to post theese to the Windows Azure Service Bus Brokered Messaging service.
Has anyone created a tool (and is willing to share) that will monitor a directoy and post these to the service bus?
Alternative, has anyone implemented an FTP server that will accept files and then post to the service bus?
Alternative, implementet FTP server in Azure that transforms messages to the service bus?
Sort of. I use the Sync Framework instead. Take a look at the File Sync Provider.
In my case, I went ahead and created a custom FTP sync provider to handle some aspects of the sync process that were specific to the application. When the sync session finishes, I post BrokeredMessages to a ServiceBus queue, where worker instances process those messages (mostly Uri's to the location of the files now in Blob Storage).
Good luck!
I have found this solution as well now: http://ftp2azure.codeplex.com/

Categories

Resources