如何将Azure Web App连接到Azure SQL数据库 [英] How to Connect Azure Web App to Azure SQL Database

查看:165
本文介绍了如何将Azure Web App连接到Azure SQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与一年前相比,Azure与一年前相比发生了一些变化.

Azure has changed a fair bit from a year ago when I played with it.

我的Azure资源组中有一个Web应用程序和一个Sql DB.我希望我的Web应用程序可以从数据库中读取.我制定了防火墙规则,以便我的应用程序可以从我的工作站上的数据库读取(在本地运行),这很好.但是我希望我的应用程序在部署时能够从数据库中读取.

I have a web app, and a Sql DB in my Azure resource group. I want my web app to read from my DB. I made a firewall rule so that my app can read from the DB at my workstation (running locally), and that is fine. But I want my app to read from the DB when it is deployed.

我是否只是制定了一条SQL防火墙规则,以将应用程序的IP地址托管到数据库中?还是有一种方法可以告诉azure Web应用程序和DB在同一个资源组中,并且它是安全的连接?也许他们可以在内部连接上相互通信?

Do I just make a sql firewall rule to allow the app's IP address when hosted through to the DB? Or is there a way I can tell azure that the web app, and the DB in the same resource group,and it is a secure connection? Perhaps that they could communicate with each other on an internal connection?

我认为在旧的Azure中,您可以链接"应用程序和数据库,并且可以完成此操作.但是不确定更新的Azure中的过程是什么.

I think in the old Azure you could 'link' an app and a DB and it accomplished this. But not sure what the procedure is in the updated Azure.

推荐答案

转到您的Azure SQL数据库并获得连接字符串的副本. (它没有您的密码,因此您必须在一分钟内将其添加.

Go to your Azure SQL Database and get a copy of the connection string. (It won't have your password, so you'll have to add that in a minute.

下一步,转到您的Web应用程序,单击所有设置",然后在下面单击应用程序设置".

Next, go to your Web App, click on the "All Settings" and under then click "Application Settings".

向下滚动到连接字符串",然后创建一个新的连接字符串(并从第一步粘贴到其中)或更新现有的连接字符串.确保更新您的连接字符串中的密码.

Scroll down to "Connection Strings" and either create a new connection string (and paste it in from the first step) or update the existing connection string. Be sure to update the password in your connection string.

如果您创建一个新的连接字符串,请确保它与您在代码中引用的名称相同,否则您将不得不更改代码并重新部署.

If you create a new connection string, make sure it's the same name as that one you are referencing in your code or you will have to change your code and redeploy as that as well.

这篇关于如何将Azure Web App连接到Azure SQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆