小孩黑眼圈很重是什么原因| 送奶奶什么礼物好| 推车是什么意思| 上什么环最好最安全伤害小| 淋巴结肿大吃什么食物好| 做梦梦见马是什么意思| 睡久了头疼是什么原因| sos代表什么| 嘴唇轻微发麻什么病兆| deep是什么意思| 士字五行属什么| 牙体牙髓科看什么| 土龙是什么鱼| 腮腺炎吃什么| 句号是什么意思| 胸痛是什么原因导致的| 什么样的电动牙刷好| 皮下男是什么意思| 宫颈筛查hpv阳性是什么意思| 吃茴香有什么好处和坏处| 肾积水是什么症状| 胆固醇高是什么| 薄荷脑是什么东西| 什么是凯格尔运动| 温开水冲服是什么意思| 山楂和什么泡水喝减肥效果最好| 鲔鱼是什么鱼| 什么持不什么| AX是什么意思| 瑶浴spa是什么意思| 感冒可以吃什么| 什么是马克杯| 青蛙是什么生肖| 康什么大道| 吃什么不上火| 胎监是检查什么的| 舌根痛吃什么药好得快| 喉咙发炎吃什么药好得快| 心脏早搏是什么症状| 送男性朋友什么礼物合适| 瑄五行属什么| 打呼噜吃什么药| 人生意义是什么| 4月出生是什么星座| 烟囱是什么意思| 水煮肉片用什么肉| 八五年属什么| luky是什么意思| 人间烟火是什么意思| 梦见死尸什么预兆| 首发是什么意思| 陕西八大怪是什么| 什么颜色最吸热| 改善记忆力吃什么药好| 男人不尊重你说明什么| 梦见儿子小时候是什么意思| 下面痒用什么药效果好| 阴虚体质是什么症状| 头晕挂什么科室| 干咳吃什么药效果好| 我要控制我自己是什么歌| 殊途同归是什么意思| 什么面不能吃| 鼻子流黄水是什么原因| 世界上最小的长度单位是什么| 冲猴煞北是什么意思| 葫芦代表什么寓意| w3是什么意思| 支气管炎吃什么药好| 七月十四号是什么星座| 癸酉五行属什么| 吃什么解腻| 窦性心律逆钟向转位是什么意思| 子不孝父之过下一句是什么| 下过海是什么意思| 龙虾的血是什么颜色的| 板栗不能和什么一起吃| 上山下金是什么字| 不以为然是什么意思| 梵高是什么画派| 藕带是什么| 冠脉cta是什么检查| 比劫是什么意思| 妇科臭氧治疗的作用是什么| 双向情感障碍是什么病| 90年属什么生肖| 左后背疼什么原因| 人瘦了是什么原因| 丁香茶有什么作用和功效| 复三上坟是什么意思| 什么是早教机| 身上长小红痣是什么原因| 双侧甲状腺弥漫病变是什么意思| 内裤上有黄色分泌物是什么原因| 血红蛋白偏低什么意思| 属马五行属什么| 心脏搭桥后最怕什么| 脂肪燃烧是什么感觉| 智齿什么时候拔最好| 高血压吃什么水果好| 王字旁和什么有关| 霉菌孢子是什么意思| 常喝黑苦荞茶有什么好处| 缺席是什么意思| 嬴稷和嬴政是什么关系| 复合维生素b片主治什么病| 天珠有什么作用与功效| 小孩子黑眼圈重是什么原因| 舞是什么结构| 美国为什么要打伊朗| 天麻炖什么治疗头痛效果最好| 五行白色属什么| 牛肉饺子配什么菜好吃| 金骏眉是什么茶类| 睑缘炎用什么药| 燕子喜欢吃什么| 女人吃秋葵有什么好处| 怀孕前三个月忌吃什么| 4月2号什么星座| fdp偏高是什么原因| 肠系膜淋巴结炎吃什么药最有效| 乳房挂什么科| 原来是什么意思| 双是什么意思| 接触性皮炎用什么药膏| 起酥油是什么做的| cabbeen是什么牌子| 神经性皮炎用什么药膏效果最好| 为什么会突然得荨麻疹| 脸上容易出油是什么原因| 多囊卵巢综合症是什么原因造成的| 1956属什么生肖| 泡脚什么时候泡最好| 实时更新是什么意思| 仰面朝天是什么生肖| 后羿属什么生肖| 啤酒加味精有什么作用| 头出虚汗是什么原因引起的| 盆腔炎做什么检查能查出来| hm平方是什么单位| 长期服用丙戊酸钠有什么副作用| 汗疱疹是什么原因引起的| 中暑吃什么水果| 尿葡萄糖高是什么原因| 什么食物对肝有好处| 四月十八日是什么日子| 免疫抑制剂是什么意思| 脊椎挂什么科| 剖腹产什么时候可以洗澡| 喝苦荞茶有什么好处和坏处| 双签是什么意思| 男性看下面挂什么科室| 牙医靠什么吃饭| 山楂不能和什么一起吃| 蓟类植物是什么| 眼花缭乱什么意思| 疥疮是什么| 回煞是什么意思| 什么是原则性问题| 豌豆淀粉可以做什么| 何去何从是什么意思| 一月27日是什么星座| 今天什么日子老黄历| 世界上最可怕的动物是什么| 溃疡是什么原因引起的| 什么木头的菜板最好| 脾胃虚寒有什么症状| 好机车是什么意思| 光宗耀祖是什么意思| 和南圣众是什么意思| 三班两倒是什么意思| dg是什么| 什么植物最老实| 什么是丛林法则| 肩周炎是什么原因造成的| 为什么会拉水| 大运是什么意思| 1921年是什么年| 胰腺在人体起什么作用| 畸形是什么意思| 感染幽门螺旋杆菌会出现什么症状| 曹操的父亲叫什么名字| 小猫来家里有什么预兆| 低筋面粉是什么| 沙特是什么教派| 未加一笔是什么字| 苦瓜对肝脏有什么好处| 健脾吃什么食物| 1954年属什么| 睾丸疼挂什么科| 长宽高用什么字母表示| 清明节与什么生肖有关| 体重下降是什么原因| 智能手环是干什么用的| 吃什么可以抗衰老| 平日是什么意思| 长红疹是什么原因| 蚯蚓用什么呼吸| nc是什么| 六月二十四是什么日子| 金银花搭配什么泡水喝好| ntd是什么意思| feedback是什么意思| 相濡以沫是什么生肖| 肛门有灼烧感什么原因| 乳酸脱氢酶是什么| 放疗和化疗有什么区别| 木瓜不能和什么一起吃| 中耳炎是什么引起的| 为什么长白头发| 摩什么擦什么| 胰腺炎是什么引起的| 高什么阔什么| 大便恶臭是什么原因| 孕妇拉肚子是什么原因引起的| 怔忡是什么意思| 消化不良吃什么药最好| 孕晚期吃什么长胎不长肉| 禄蠹是什么意思| 暗渡陈仓什么意思| 暗喻是什么意思| 水保是什么| 牙齿过敏吃什么药| 胃病忌什么| 嘴唇暗红色是什么原因| 氮泵是什么| 观音菩萨的坐骑是什么| 什么叫筋膜炎| 真菌感染是什么意思| 打嗝不停是什么原因| 什么的生长| 中国文字博大精深什么意思| 怀孕血压高对胎儿有什么影响| 舌苔黄厚吃什么药| 蛋白粉什么时间喝最好| 新生儿为什么有黄疸| 为什么会自言自语| 右手臂酸痛是什么前兆| 经常干咳是什么原因| 手指有痣代表什么意思| 脾虚湿盛吃什么药| 稍高回声是什么意思| 看破红尘是什么意思| 23号来月经什么时候是排卵期| 孕妇喝什么补羊水最快| 梦见很多蜜蜂是什么意思| 低密度脂蛋白偏高吃什么食物| 想要孩子需要做什么检查| 同一首歌为什么停播了| 输钾为什么会痛| 老年人吃什么营养品好| 7月25日是什么星座| 孕妇吃什么水果| 全性向是什么意思| 备孕要注意什么| 儒雅什么意思| 乳酸菌是什么菌| 被紫外线灯照到有什么后果呀| 地势是什么意思| 梦见做鞋子是什么意思| 空灵是什么意思| 尿道痒痒是什么原因| 218是什么星座| 黄什么什么| 百度

Try to extend agent mode in VS Code!

Blue Gecko BGM111 Bluetooth Smart 模块数据表

百度 及时适应移动化需求,各站可以根据本地情况,本地化凤凰早班车、今日土拍、图图说房等知名品牌栏目;更可以满足各站多样化的定制化需求,根据实际需求推出适合本站的楼市大视野、地产面对面、凤眼看房、光影美宅等特色栏目。

In this tutorial, you will learn how to:

  • Create a Dockerfile file describing a simple Python container.
  • Build, run, and verify the functionality of a Django, Flask, or General Python app.
  • Debug the app running in a container.

Prerequisites

  • Install Docker on your machine and add it to the system path.

  • On Linux, you should also enable Docker CLI for the non-root user account that will be used to run VS Code.

  • The Container Tools extension. To install the extension, open the Extensions view (??X (Windows, Linux Ctrl+Shift+X)), search for container tools to filter results and select the Container Tools extension authored by Microsoft.

    Select Container Tools extension

Create a Python project

If you don't have a Python project already, follow the tutorial Getting started with Python.

Note: If you want to containerize a complete Django or Flask web app, you can start with one of the following samples:

Note: For this tutorial, be sure to use the tutorial branch of the sample repos.

After verifying your app runs properly, you can now containerize your application.

Add Docker files to the project

  1. Open the project folder in VS Code.

  2. Open the Command Palette (??P (Windows, Linux Ctrl+Shift+P)) and choose Containers: Add Docker Files to Workspace...:

    Add Dockerfile to a Python project

  3. When prompted for the app type, select Python: Django, Python: Flask, or Python: General as the app type. For this tutorial, we'll focus on the Python: General case, but will also include notes for Django and Flask.

  4. Enter the relative path to the app's entry point. This excludes the workspace folder you start from. If you created a python app with hello.py according to the Getting Started with Python tutorial, choose that.

    Django: Choose manage.py (root folder) or subfolder_name/manage.py. See the official Django documentation.

    Flask: Choose the path to where you create your Flask instance. See the official Flask documentation.

    Tip: You may also enter the path to a folder name as long as this folder includes a __main__.py file.

  5. Select the port number. We recommend selecting port 1024 or above to mitigate security concerns from running as a root user. Any unused will port, but Django and Flask use standard default ports.

    Django: The default port 8000.

    Flask: The default port is 5000.

  6. When prompted to include Docker Compose, select No if you do not want a Docker Compose file. If you select Yes, you will need to verify the path to your wsgi.py file in the Dockerfile to run the Compose Up command successfully. Compose is typically used when running multiple containers at once.

  7. With all this information, the Container Tools extension creates the following files:

    • A Dockerfile. To learn more about IntelliSense in this file, refer to the overview.

    • A .dockerignore file to reduce the image size by excluding files and folders that aren't needed such as .git, .vscode, and __pycache__.

    • If you're using Docker Compose, a docker-compose.yml and docker-compose.debug.yml file.

    • If one does not already exist, a requirements.txt file for capturing all app dependencies.

    Important Note: To use our setup, the Python framework (Django/Flask) and Gunicorn must be included in the requirements.txt file. If the virtual environment/host machine already has these prerequisites installed and is supposed to be identical to the container environment, ensure app dependencies are ported over by running pip freeze > requirements.txt in the terminal. This will overwrite your current requirements.txt file.

(Optional) Add an environment variable to the image

This step is not required, but it is included to help you understand how to add environment variables that need to be set in the container's environment.

The Container Tools extension helps you author Dockerfiles by using IntelliSense to provide auto-completions and contextual help. To see this feature in action:

  1. Open the Dockerfile.

  2. Underneath the EXPOSE statement, type ?Space (Windows, Linux Ctrl+Space) to trigger IntelliSense and scroll to ENV.

    Adding environment variable to Dockerfile

  3. Press Tab or Enter to complete the statement, then set the key to the name of the variable, and set the value.

For more information about setting and using environment variables in the Dockerfile, see the ENV instruction and Environment replacement section in the Docker documentation.

Gunicorn modifications for Django and Flask apps

To give Python web developers a great starting point, we chose to use Gunicorn as the default web server. Since it is referenced in the default Dockerfile, it is included as a dependency in the requirements.txt file. If you don't see it in requirements.txt, run pip install gunicorn and then run pip freeze > requirements.txt to regenerate the requirements.txt file.

  • Django: To use Gunicorn, it must bind to an application callable (what the application server uses to communicate with your code) as an entry point. This callable is declared in the wsgi.py file of a Django application. To accomplish this binding, the final line in the Dockerfile says:

    CMD ["gunicorn", "--bind", "0.0.0.0:8000", "{workspace_folder_name}.wsgi"]
    

    If your project does not follow Django's default project structure (that is, a workspace folder and a wsgi.py file >within a subfolder named the same as the workspace) you must overwrite the Gunicorn entry point in the Dockerfile to locate the correct wsgi.py file.

    If your wsgi.py file is in the root folder, the final argument in the command above will be "wsgi". Within subfolders, the argument would be "subfolder1_name.subfolder2_name.wsgi".

  • Flask: To use Gunicorn, it must bind to an application callable (what the application server uses to communicate with your code) as an entry point. This callable corresponds with the file location and variable name of your created Flask instance. According to official Flask Documentation, users generally create a Flask instance in the main module or in the __init__.py file of their package in this manner:

    from flask import Flask
    app = Flask(__name__) # Flask instance named app
    

    To accomplish this binding, the final line in the Dockerfile says:

    CMD ["gunicorn", "--bind", "0.0.0.0:5000", "{subfolder}.{module_file}:app"]
    

    During the Containers: Add Docker Files to Workspace... command, you configure the path to the Flask instance, however, the Container Tools extension assumes your Flask instance variable is named app. If this is not the case, you must change the variable name in the Dockerfile.

    If your main module was in the root folder as a file named main.py and had a Flask instance variable was named myapp, the final argument in the command above will be "main:myapp". Within subfolders, the argument would be "subfolder1_name.subfolder2_name.main:myapp".

Build, run, and debug the container

The Containers: Add Docker Files to Workspace... command automatically creates a Docker launch configuration to build and run your container in debug mode. To debug your Python app container:

  1. Navigate to the file that contains your app's startup code, and set a breakpoint.

  2. Navigate to Run and Debug and select Containers: Python - General, Containers: Python - Django, or Containers: Python - Flask, as appropriate.

    Selected container debug configuration

  3. Start debugging using the F5 key.

    • The container image builds.
    • The container runs.
    • The python debugger stops at the breakpoint.
  4. Step over this line once.

  5. When ready, press continue.

The Container Tools extension will launch your browser to a randomly mapped port:

Django website launches

Tip: To modify your Docker build settings, such as changing the image tag, navigate to .vscode -> tasks.json under the dockerBuild attribute in the docker-build task. Use IntelliSense within the file (?Space (Windows, Linux Ctrl+Space)) to display all other valid directives.

Use the Container Explorer

The Container Explorer provides an interactive experience to examine and manage container assets such as containers, images, and so on. To see an example:

  1. Navigate to the Container Explorer.

  2. In the Containers tab, right-click on your container and choose View Logs.

    Viewing the logs of a container

  3. The output will be displayed in the terminal.

Build the image in Azure

You can use the command Azure Container Registry: Build Image in Azure to build an image that you can then deploy to Azure App Service or Azure Container Apps.

  1. Install the Azure Resources extension. Open the Command Palette (??P (Windows, Linux Ctrl+Shift+P)) and search for the command Azure: Sign In. If you don't have an Azure account, you can sign up for a free trial.

  2. There are two ways to invoke the build in Azure command. You can right-click on the Dockerfile, and choose Build Image in Azure. You can also use the Command Palette (??P (Windows, Linux Ctrl+Shift+P)) and search for the command Azure Container Registry: Build Image in Azure.

    Invoke the command Build Image in Azure

  3. Choose the name and tag for the built image. You'll use this to identify it in the container registry.

    Choose the name and tag for the built image.

  4. Choose the Azure subscription you want to use.

  5. Choose an existing Azure Container Registry, or create a new one. When you create a new one, you're asked to provide the name, resource group, location, and an option for pricing, such as Basic, Standard, or Premium. You can read about the costs of these options at Pricing - Container Registry.

  6. Specify the base OS, Linux or Windows. This choice must be consistent with the Dockerfile.

    Choose the base OS for the built image

The process of building the image might take a few minutes. You can track progress in the terminal. If you encounter an error (Error: failed to download context.), try using the Refresh option on the container registry and then request another build. Before rebuilding, manually delete the old image.

Deploy to Azure App Service or Azure Container Apps

Once the container image is built, it should appear in the Container Registry with the tag you specified. Now that it's built, you can deploy it to Azure App Service or Azure Container Apps. The Azure App Service extension is recommended for deployments to Azure App Service, and the Azure Container Apps extension is required for deployments to Azure Container Apps. You can obtain both if you install the Azure Tools extension pack, which includes a package of tools for a wide range of Azure development scenarios.

  1. Right-click on the image tag and choose Deploy Image to Azure App Service or Deploy Image to Azure Container Apps.

    Deploy image to Azure App Service

  2. Provide the name of the web site. This must be a unique name, and for Django apps, it must also be listed as a valid host name in the ALLOWED_HOSTS list in the settings.py file.

  3. Provide a resource group, location, and App Service Plan. If you're just getting started, you can choose the free plan.

  4. The image is deployed; the process might take a few minutes. Once it's deployed, a notification appears with a button you can use to access the site. You can also use the site's address, {appname}.azurewebsites.net where {appname} is the name you gave when creating it. If it doesn't work at first, try again in a few minutes. It's not uncommon for the first few attempts to time out or return an error. It just means the App Service isn't ready yet to receive requests.

  5. Make a small change in the application code that's visible on one of the pages, and save the file.

  6. Use the Azure icon to open the Resources view, and expand the node for your subscription to find the App Service that you deployed in the previous step.

  7. Right-click on the App Service node and look at the available options. Choose Deploy to Web App, and then specify your app folder to deploy it.

    Deploy to Web App

    When warned that this will overwrite the previous deployment, choose Deploy to confirm.

    This might take a few minutes; you can monitor progress in the terminal window. When it finishes, a button with access to the site is given.

    Browse website button

    Use the button and verify that your change is reflected on the site.

Congratulations, you've used Python in VS Code to create an deploy a web site that's hosted in the cloud and live on the internet!

Free up resources

In the Azure portal, delete the Resource Group to free up all resources that you created during this exercise.

Next steps

You're done! Now that your container is ready, you may want to:

屙是什么意思 感冒可以吃什么 crew是什么意思 老人经常便秘有什么好办法 2月2日是什么星座
香港说什么语言 爬楼是什么意思 伟哥有什么副作用 急性肠胃炎能吃什么水果 金银花泡水喝有什么好处
blackpink什么意思 小孩上吐下泻吃什么药 不议价什么意思 喉咙痛吃什么 一个石一个夕念什么
全职太太是什么意思 鱼平念什么 经常感冒的人吃什么能增强抵抗力 太阳穴疼是什么原因 产后抑郁一般发生在产后什么时间
牙齿出血是什么病表现出来的症状hcv7jop6ns2r.cn 三个牛读什么字hcv9jop3ns8r.cn 999是什么意思hcv8jop0ns5r.cn 三个直念什么hcv9jop5ns3r.cn 农历闰月有什么规律hcv9jop3ns6r.cn
成五行属性是什么hcv8jop6ns9r.cn 吃醪糟有什么好处hcv9jop6ns9r.cn 为什么手比脸白那么多hcv8jop3ns5r.cn pdc是什么意思hcv8jop3ns1r.cn 女性多吃什么滋补卵巢hcv7jop9ns5r.cn
男大三后面一句是什么hcv9jop1ns8r.cn 美国为什么叫鹰酱hcv8jop4ns9r.cn 项羽为什么叫西楚霸王hcv8jop9ns2r.cn 肝不好吃什么药效果好hcv7jop7ns1r.cn 浮想联翩什么意思hcv8jop7ns4r.cn
西瓜不能和什么一起吃hcv7jop5ns5r.cn 梦见嫖娼是什么意思hcv9jop2ns8r.cn 眼睛感染用什么眼药水hcv9jop4ns0r.cn 世界最大的岛是什么岛hcv8jop4ns6r.cn 做梦梦见离婚是什么意思hcv8jop0ns1r.cn
百度