App service creation queries

sns 9,246 Reputation points
2023-05-27T11:39:48.5066667+00:00

I have used following commands in azure cli, I understood that it creates the web app and deploy the dotnet code in to app service.

User's image

I could see web app loading perfectly fine as expected.

however I am not clear, could you please clarify my following 3 questions:

  1. If developers give python code do I need to execute command as below? am I correct?

python new webapp -n webapp

  1. Please clarify 2nd command from above screenshot
  2. we use azure webapp create command to create azure app service, but what is the significance of "azure webapp up" here? in the 3rd command , Please clarify

Thank you

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,936 questions
{count} votes

Accepted answer
  1. ajkuma 28,036 Reputation points Microsoft Employee Moderator
    2023-06-02T18:48:44.97+00:00

    @sns , Thanks for the follow-up.

    The doc outlines step by step instructions on deploying the Python WebApp (Django or Flask), in your case, instead of sample application, you could push the application code (that your dev team provides). I'm sharing below detailed steps:

    1.    Ensure that you have the latest Azure CLI installed on your machine.

    2.    Open a terminal or command prompt and navigate to the root directory of your Python app.

    3.    Create a new resource group for your app using the following command:

    az group create --name <resource-group-name> --location <location>
    

    Replace <resource-group-name> with the name you want to give your resource group, and <location> with the Azure region you want to deploy to.

    4.    Create a new Azure App Service plan using the following command:

      az appservice plan create --name <app-service-plan-name> --resource-group <resource-group-name> --sku B1 --is-linux
    

    Replace <app-service-plan-name> with the name you want to give your app service plan, and <resource-group-name> with the name of the resource group you created in step 3.

    5.    Create a new web app using the following command:

    az webapp create --name <app-name> --resource-group <resource-group-name> --plan <app-service-plan-name> --runtime "PYTHON|3.9" --deployment-local-git
    

    Replace <app-name> with the name you want to give your web app, <resource-group-name> with the name of the resource group you created in step 3, and <app-service-plan-name> with the name of the app service plan you created in step 4.

    (Azure App service supports multiple methods to deploy your application code to Azure including support for GitHub Actions and all major CI/CD tools. Here, we are  focuses on how to deploy your code from your local workstation to Azure/via Git)

     

    6.    Set the deployment credentials for your web app using the following command:

         

         az webapp deployment user set --user-name <username> --password <password>
    

    Replace <username> with the username you want to use for deployment, and <password> with the password you want to use for deployment.

     

    1. To deploy updates to your app, you can use Git deployment. First, run the following command to get the Git URL for your app:
    az webapp deployment source config-local-git --name <app-name> --resource-group <resource-group-name>
    

    8.Copy the Git URL that is returned by the command.

    9.In your local app directory, initialize a new Git repository and add your code:

    git init
    git add . 
    git commit -m "Initial commit"
    
    1. Add the Azure remote repository as a Git remote:
    git remote add azure <git-deployment-url>
    

    (Deploy your Python code to the web app using Git. First, add the Azure App Service Git remote to your local Git repository)

    Replace <git-deployment-url> with the Git URL you copied in step 7.

     

    11.Push your code to the Azure remote repository:

     git push azure master
    

    Additional resources:

    Configure a Linux Python app for Azure App Service

    Use CI/CD to deploy a Python web app to Azure App Service on Linux

    This will deploy your code to Azure App Service.

    I hope this helps! Let me know if you have any further questions.


    If the answer helped (pointed you in the right direction) > please click Accept Answer

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. TP 124.9K Reputation points Volunteer Moderator
    2023-05-27T12:48:32.3266667+00:00

    Hi,

    When you run dotnet new what you are doing is creating the scaffold for a new application. This is unrelated to Azure App Service. What I mean by saying "unrelated" is you could use dotnet new to create a WPF application, or any of the other supported types, and deploy it somewhere else besides App Service if you wanted.

    The above is common pattern for development frameworks/libraries/etc. They will have a command line interface, and a certain command that you run to create a new application with a set of default folders/files (aka scaffold). In a sense you can think of it as a shortcut for developers to start a new application project.

    You would only run dotnet new if you were creating a new application for some reason.

    az webapp up creates a new webapp on Azure App Service and uploads the application in the current folder. Compare this to az webapp create which also creates a new webapp on Azure App Service, however, it doesn't upload the application files--you need to do that in a separate step.

    In regards to Python, if a developer gives you a Python application you would want to deploy that to an Azure App Service App using one of the methods available, like az webapp up. To my knowledge "python new" isn't a valid command, but regardless, you wouldn't want to create a new Python application since you would already have what the developers gave you.

    Please click Accept Answer if the above was helpful. Please let me know if something I wrote wasn't clear.

    Thanks.

    -TP


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.