Azure Web Role apply https binding to multiple instances - asp.net-mvc

I have two web roles scaled up to 4 instances and at least two instances are running at a time. The certificate requested by a user via first website is pushed to blob storage and creates a queue message for the other website to read it.
I have a while loop inside the Run method implementing RoleEntryPoint to check the message, upload the certificate to store if available, apply https binding, and delete the message.
The bindings are applied to current instance and not into both. Is there a way to I can access all instances and apply bindings to both at once? If not, what are some better approaches?

Related

Run Docker containers dynamically according to DB?

I'm developing an app which live-streams video and/or audio from different entities. Those entities' IDs and configurations are stored as records in my DB. My app's current architecture is something such as the following:
a CRUD API endpoint for system-wide functionalities, such as logging in or editing an entity's configuration.
N-amount of other endpoints (where N is the number of entities and every endpoint's route is defined by the specific entity's ID, like so: "/:id/api/") for each entity's specific functionalities. Each entity is loaded by the app on initialization. Those endpoints are both a REST API handler and a WebSocket server for live-streaming media received from the backend which was configured for that entity.
On top of that, there's an NGINX instance which acts as a proxy and hosts our client files.
Obviously, this isn't very scalable at the moment (a single server instance handles an ever-growing amount of entities) and requires restarting my server's instance when adding/deleting an entity - which isn't ideal. I was thinking of splitting my app's server into micro-services: one for system-wide CRUD, and N others for each entity defined in my DB. Ultimately, I'd like those micro-services to be run as Docker containers. The problems (or questions to which I don't know the answers) I'm facing at the moment are:
How does one run Docker containers dynamically, according to a DB (or programmatically)? Is it even possible?
How does one update the running Docker container to be able to reconfigure that entity during run-time?
How would one even configure NGINX to proxy those dynamic micro-services? I'm guessing I'll have to use something like Consul?
I'm not very knowledgeable, so pardon me if I'm too naive to think I can achieve such architecture. Also, if you can think of a better architecture, I'd love to hear your suggestions.
Thanks!

Keeping data in sync between IdentityServer and application

I use IdentityServer4 (with Asp.Net Core Identity) as a centralized auth point for multiple applications.
In one of the applications I want to setup a scheduled job to send out e-mail notifications to multiple users. When the job will execute, it will have no access to user claims (as it will execute not in the context of a single user request) and thus there will be no place to read user's e-mail from. This means I will have to duplicate e-mails in the application DB.
But how to keep e-mails in sync between the app and the IdentityServer if some user wants to change it?
A good approach would be to implement integration events in your system. This is a mechanism that raises an event 'This special thing happend', and allows other parts of your system to be notified.
You can use RabbitMQ or Azure ServiceBus for example to send messages to. Every system being subscribed to that kind of message, will receive it.
So in your case, you would create an event called UserChangedEmailAddressIntegrationEvent for example. Then in your emailing system, you subscribe to exact this event. Once it's raised, your emailing system will receive the message and be able to handle it.
The UserChangedEmailAddressIntegrationEvent could in fact be a class, containing (for example) two properties, OldEmail and NewEmail so the emailing system knows what value to change.
See the eShopOnContainers example project, which has this exact technique implemented
https://github.com/dotnet-architecture/eShopOnContainers
We have faced a similar problem where we had Hangfire jobs running that would extract reporting data from our system and then email the reports to the set of users configured when creating the scheduled job.
We also used Identity Server 4 with ASP.Net Identity and ended up storing the user id's on the scheduled job info. We then also created an api endpoint on our ASP.Net Identity that would serve back the required user info given user id (or a list of user id's). Lastly, we used client_credentials and created a client to consume that api during the job execution that would retrieve appropriate user info at a given point in time from our ASP.Net Identity api.
Such approach has worked well for us so far and it removed the pain of having to think about how to ensure data syncing all together.

Reinitialize Parse iOS SDK with a new server URL

I'm wondering if there is some way to stop the Parse client and reinitialize it with a new server URL. I'm not seeing any method to do so, so I don't have any attempts to show.
My use case is this: I have two main segments of my users, customers and providers. They use the app pretty differently, and we think as we scale, we could benefit from hosting the backend on different servers connected to the same database, so that we can use the most cost efficient machines and configurations for each case on AWS.
However, we currently use one app, and just send the user to the appropriate side of the app when they login. Ideally, we'd like to not have to re-work entirely to release two separate apps, one for customers and one for providers.
I would like to have a third separate login server, which will be what is initialized when the app is first opened. Once a user logs in, it would fetch their user, then re-initialize the Parse client to one of the other servers depending on whether the user was a customer or provider.
Is this feasible at all with the current SDK, or is the only way to have separate backend servers going to be to have separate client side apps as well?

cloud foundry is providing same instance of my web page to every device

Lets say there is some static variables in a class and when user on device 1 store some data on it and at the same time some other user on device 2 open the web page then he/she also gets the same data store in that variable,,insted of the deafult data i store .
I think cloud Foundry provide different isolated environment to every user that goes on the website but in that case that is not happening.
Please do tell if this the same behavior what cloud foundry really provide or i am missing something .
cloud Foundry provide different isolated environment to every user that goes on the website
That statement is absolutely not true. Each instance of an application does get an isolated execution environment, but CF creates exactly as many application instances as you tell it to (e.g. via the -i parameter on cf push or cf scale). The platform does not scale up instances per user. No platform I know of does that, as it would be incredibly inefficient.
If your web application needs to keep unique data for each user of the app, it will need to implement session management logic inside the app. You can't do this with static fields in classes. Exactly how you implement session management is dependent on the language and frameworks you are using.

Windows azure web role

We have planned to migrate our application to web role as web role splits the server traffics to other instances. We have some queries regarding that . Let me post it one by one.
1) Since web role involves multiple instances (redirecting to different servers at run time based on the number of instances created), what happens to my session related details which was maintained in one server (with inproc mode will get resides in iis ) when my next requests gets redirected to other server where my session related details wont be available know? Do the windows azure takes a copy of that too or do we need to manully handle?
2)Our application works like Presentation Layer makes a call to the web service which in turn queries the database and results are displayed accordingly (presentation -> webservice -> database). So when am making my presenataion layer as cloud service web role obvioulsy i would need to make my service also as a web role . Am i right?
2.1) If so, what happens when am making the request from presentation how the requests will get carried ?
2.2) Am having my database in a separated vm (not azure db) hosted in sql express when the service dynamically
creates multiple instances what happens to database part?
2.3) Shall we host service and presenation in same cloud service or different which will be preferrable one?

Resources