Azure Webjob handling

KANAKAM, HEMANTH RAJA 0 Reputation points
2025-03-31T17:50:25.4866667+00:00

Hi, My name is Hemanth.

Based on my requirement i have build a .net console application as an azure continuous webjob and in the code based on a condition i need to STOP the azure webjob and start it later. I have published the webjob and its available in the appservice.

  1. Im able to get the azure webjob KPIURL and username and password and using those credentials after executing my condition and using below code im able to stop the azure webjob from my local machine.

var byteArray = Encoding.ASCII.GetBytes($"{ftpUsername}:{ftpPassword}");

client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));

logger.LogInformation("Azure WebJOb Authorizing");

var response = await client.PostAsync($"{kuduApiUrl}/stop", null);

logger.LogInformation("Azure WebJOb Authorizing"+response);

if (response.IsSuccessStatusCode)

{

var content = await response.Content.ReadAsStringAsync();

logger.LogInformation("WebJob stopped successfully: " + content);

}

else

{

var errorContent = await response.Content.ReadAsStringAsync();

logger.LogError($"Error stopping WebJob: {response.StatusCode} - {errorContent}");

}

  1. But with the same credentails when i published the code , its not able to STOP. after var response = await client.PostAsync($"{kuduApiUrl}/stop", null); its saying no such host is known. im using kpiurl as and username and password from azure webjob. I have verified VNet integrations or network restrictions (e.g., private endpoints, service endpoints, or access restrictions) that might block DNS resolution or outbound traffic. and Azure's default DNS servers is allowed...
  2. so at this point im not sure what is the issue and how to make it work?...in my case my application is present in the Appservice and my azureweb job code is under webjobs as continuous. Please help how to resolve this issue?
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,937 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Prabhavathi Manchala 2,390 Reputation points Microsoft External Staff Moderator
    2025-04-02T18:57:45.67+00:00

    Hi KANAKAM, HEMANTH RAJA,

    The error No such host is known typically indicates a DNS or network issue preventing your App Service from resolving the Kudu API. Verify that the kuduApiUrl is correctly formatted https://<your-app-name>.scm.azurewebsites.net/api/. Check for network restrictions like VNet integration, NSGs, or outbound traffic limits. Ensure authentication settings, such as Azure AD, are not blocking access. Also, enabling Always On may be required for proper functionality.

    • Please make sure your App Service can reach the Kudu API by running the following command in the Kudu Console yourappname.scm.azurewebsites.net
    nslookup yourappname.scm.azurewebsites.net
    

    If this fails, your App Service has a DNS or network restriction.

    • Please allow Outbound Access to Kudu API, if using a VNet, Private Endpoints, or NSGs, check outbound settings in Azure Portal > App Service > Networking. Ensure DNS resolution works, and outbound traffic isn't blocked. In Access Restrictions, allow traffic to *.scm.azurewebsites.net.
    • Avoid issues by using Managed Identity instead of hardcoded credentials.

    Enable Managed Identity in Azure Portal > App Service > Identity > System Assigned by turning it ON.

    Assign the Contributor or WebJob Contributor role to your App Service's Managed Identity in Azure Portal > Subscription or Resource Group > Access Control (IAM).

    Update your code to use Managed Identity instead of username/password for Kudu API authentication.

    var azureCredential = new DefaultAzureCredential();
    var accessToken = await azureCredential.GetTokenAsync(new TokenRequestContext(new[] { "https://management.azure.com/.default" }));
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Token);
    var response = await client.PostAsync($"{kuduApiUrl}/stop", null);
    
    • Check App Service Logs in Azure Portal > Diagnose and Solve Problems for network issues and detailed error messages.

    Check the link below for more details on this issue.

    https://learn.microsoft.com/en-us/answers/questions/1150723/unable-to-stop-the-continuous-webjob-deployed-from

    Please accept as "Yes" if the answer provided is useful, so that you can help others in the community looking for remediation for similar issues.

    Let me know if you have any further Queries.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.