Singleton Azure function running as separate instances
We have an Azure function that is supposed to be handling several service bus triggers at the same time and what I assume is happening is that it is being split across several instances which is causing some concurrency problems on our end.
We need our function to act as a singleton so we can process requests one at a time without any collisions. From what we looked into in this article (https://docs.microsoft.com/en-us/azure/app-service/webjobs-sdk-how-to#singleton-attribute) we should be able to accomplish this.
Our function looks like this:
[Microsoft.Azure.WebJobs.Singleton(Mode = SingletonMode.Listener)]
[FunctionName("AccountCreatedSubscriber")]
public static void Run([ServiceBusTrigger("accountscontacts-account-created", "license-keys", Connection = "FBISEventBus")]BrokeredMessage message, ILogger log)
{
log.LogInformation($"{{ Message received from accountscontacts-account-created topic }}");
// Do Work
log.LogInformation($"{{ Message sent to account creation handler }}");
}
And for backup we also have this in our host.json file,
{
"serviceBus": { "maxConcurrentCalls": 1 }
}
But for whatever reason our functions are still running parallel. Any ideas?
c# azure concurrency azure-functions
add a comment |
We have an Azure function that is supposed to be handling several service bus triggers at the same time and what I assume is happening is that it is being split across several instances which is causing some concurrency problems on our end.
We need our function to act as a singleton so we can process requests one at a time without any collisions. From what we looked into in this article (https://docs.microsoft.com/en-us/azure/app-service/webjobs-sdk-how-to#singleton-attribute) we should be able to accomplish this.
Our function looks like this:
[Microsoft.Azure.WebJobs.Singleton(Mode = SingletonMode.Listener)]
[FunctionName("AccountCreatedSubscriber")]
public static void Run([ServiceBusTrigger("accountscontacts-account-created", "license-keys", Connection = "FBISEventBus")]BrokeredMessage message, ILogger log)
{
log.LogInformation($"{{ Message received from accountscontacts-account-created topic }}");
// Do Work
log.LogInformation($"{{ Message sent to account creation handler }}");
}
And for backup we also have this in our host.json file,
{
"serviceBus": { "maxConcurrentCalls": 1 }
}
But for whatever reason our functions are still running parallel. Any ideas?
c# azure concurrency azure-functions
add a comment |
We have an Azure function that is supposed to be handling several service bus triggers at the same time and what I assume is happening is that it is being split across several instances which is causing some concurrency problems on our end.
We need our function to act as a singleton so we can process requests one at a time without any collisions. From what we looked into in this article (https://docs.microsoft.com/en-us/azure/app-service/webjobs-sdk-how-to#singleton-attribute) we should be able to accomplish this.
Our function looks like this:
[Microsoft.Azure.WebJobs.Singleton(Mode = SingletonMode.Listener)]
[FunctionName("AccountCreatedSubscriber")]
public static void Run([ServiceBusTrigger("accountscontacts-account-created", "license-keys", Connection = "FBISEventBus")]BrokeredMessage message, ILogger log)
{
log.LogInformation($"{{ Message received from accountscontacts-account-created topic }}");
// Do Work
log.LogInformation($"{{ Message sent to account creation handler }}");
}
And for backup we also have this in our host.json file,
{
"serviceBus": { "maxConcurrentCalls": 1 }
}
But for whatever reason our functions are still running parallel. Any ideas?
c# azure concurrency azure-functions
We have an Azure function that is supposed to be handling several service bus triggers at the same time and what I assume is happening is that it is being split across several instances which is causing some concurrency problems on our end.
We need our function to act as a singleton so we can process requests one at a time without any collisions. From what we looked into in this article (https://docs.microsoft.com/en-us/azure/app-service/webjobs-sdk-how-to#singleton-attribute) we should be able to accomplish this.
Our function looks like this:
[Microsoft.Azure.WebJobs.Singleton(Mode = SingletonMode.Listener)]
[FunctionName("AccountCreatedSubscriber")]
public static void Run([ServiceBusTrigger("accountscontacts-account-created", "license-keys", Connection = "FBISEventBus")]BrokeredMessage message, ILogger log)
{
log.LogInformation($"{{ Message received from accountscontacts-account-created topic }}");
// Do Work
log.LogInformation($"{{ Message sent to account creation handler }}");
}
And for backup we also have this in our host.json file,
{
"serviceBus": { "maxConcurrentCalls": 1 }
}
But for whatever reason our functions are still running parallel. Any ideas?
c# azure concurrency azure-functions
c# azure concurrency azure-functions
edited Jan 2 at 6:29
marc_s
580k13011181266
580k13011181266
asked Jan 2 at 4:20
tokyo0709tokyo0709
6632920
6632920
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
If your function is on Consumption plan, set
WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT
to1
in Application settings.
Check your Azure Function runtime version in portal(Platform features> Function app settings). If it's ~2, we need to modify service bus setting in host.json as below.
{
"version": "2.0",
"extensions": {
"serviceBus": {
"messageHandlerOptions": {
"maxConcurrentCalls": 1
}
}
}
}
Sorry, we had tried this at first and I thought it didn't do anything for us but it was a different issue I realized and this did seem to help with some of the concurrency we were dealing with thank you.
– tokyo0709
Jan 8 at 3:59
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54001149%2fsingleton-azure-function-running-as-separate-instances%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If your function is on Consumption plan, set
WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT
to1
in Application settings.
Check your Azure Function runtime version in portal(Platform features> Function app settings). If it's ~2, we need to modify service bus setting in host.json as below.
{
"version": "2.0",
"extensions": {
"serviceBus": {
"messageHandlerOptions": {
"maxConcurrentCalls": 1
}
}
}
}
Sorry, we had tried this at first and I thought it didn't do anything for us but it was a different issue I realized and this did seem to help with some of the concurrency we were dealing with thank you.
– tokyo0709
Jan 8 at 3:59
add a comment |
If your function is on Consumption plan, set
WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT
to1
in Application settings.
Check your Azure Function runtime version in portal(Platform features> Function app settings). If it's ~2, we need to modify service bus setting in host.json as below.
{
"version": "2.0",
"extensions": {
"serviceBus": {
"messageHandlerOptions": {
"maxConcurrentCalls": 1
}
}
}
}
Sorry, we had tried this at first and I thought it didn't do anything for us but it was a different issue I realized and this did seem to help with some of the concurrency we were dealing with thank you.
– tokyo0709
Jan 8 at 3:59
add a comment |
If your function is on Consumption plan, set
WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT
to1
in Application settings.
Check your Azure Function runtime version in portal(Platform features> Function app settings). If it's ~2, we need to modify service bus setting in host.json as below.
{
"version": "2.0",
"extensions": {
"serviceBus": {
"messageHandlerOptions": {
"maxConcurrentCalls": 1
}
}
}
}
If your function is on Consumption plan, set
WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT
to1
in Application settings.
Check your Azure Function runtime version in portal(Platform features> Function app settings). If it's ~2, we need to modify service bus setting in host.json as below.
{
"version": "2.0",
"extensions": {
"serviceBus": {
"messageHandlerOptions": {
"maxConcurrentCalls": 1
}
}
}
}
edited Jan 2 at 8:25
answered Jan 2 at 5:23
Jerry LiuJerry Liu
11.3k11232
11.3k11232
Sorry, we had tried this at first and I thought it didn't do anything for us but it was a different issue I realized and this did seem to help with some of the concurrency we were dealing with thank you.
– tokyo0709
Jan 8 at 3:59
add a comment |
Sorry, we had tried this at first and I thought it didn't do anything for us but it was a different issue I realized and this did seem to help with some of the concurrency we were dealing with thank you.
– tokyo0709
Jan 8 at 3:59
Sorry, we had tried this at first and I thought it didn't do anything for us but it was a different issue I realized and this did seem to help with some of the concurrency we were dealing with thank you.
– tokyo0709
Jan 8 at 3:59
Sorry, we had tried this at first and I thought it didn't do anything for us but it was a different issue I realized and this did seem to help with some of the concurrency we were dealing with thank you.
– tokyo0709
Jan 8 at 3:59
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54001149%2fsingleton-azure-function-running-as-separate-instances%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown