AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / dba / 问题 / 250958
Accepted
sachin-SQLServernewbiee
sachin-SQLServernewbiee
Asked: 2019-10-14 08:08:48 +0800 CST2019-10-14 08:08:48 +0800 CST 2019-10-14 08:08:48 +0800 CST

托管在 Azure VM (IaaS) 上的 SQL Server 是否支持 DB 邮件?

  • 772

托管在 Azure VM (IaaS) 上的 SQL Server 中是否存在 DB 邮件?

如果不支持 DB 邮件,那么有哪些可用功能?

sql-server azure-sql-database
  • 2 2 个回答
  • 1496 Views

2 个回答

  • Voted
  1. Best Answer
    Alberto Morillo
    2019-10-15T10:28:13+08:002019-10-15T10:28:13+08:00

    数据库邮件在 Azure IaaS 上的 SQL Server 上可用,我的建议是使用 SendGrid 电子邮件传递服务(可在 Azure 市场上获得)来配置它,该服务为您的虚拟机提供 SMTP 中继。利用此服务设置数据库邮件以满足您的警报或报告需求。

    在这里,您将了解如何在 Microsoft Azure 上设置 SendGrid 服务。

    设置好 SendGrid 服务后,您可以在 SQL Server VM 上对其进行配置,如下所示。

    首先在 sp_configure 上启用它:

    /*
       Turn on database mail
    */
    
    -- Select the correct database
    USE [msdb]
    GO
    
    -- Just shows standard options
    sp_configure
    GO
    
    -- Turn on advance options
    sp_configure 'show advanced options', 1;
    GO
    
    -- Reconfigure server
    RECONFIGURE;
    GO
    
    -- Turn on database xp's
    sp_configure 'Database Mail XPs', 1;
    GO
    
    -- Reconfigure server
    RECONFIGURE
    

    接下来,创建一个电子邮件帐户:

    /*
       Creating mail account with Send Grid SMTP server
    */
    
    -- Create a Database Mail account 1
    EXEC msdb.dbo.sysmail_add_account_sp
      @account_name = 'act_Default_Email',
      @description = 'Mail account for use by all database users.',
      @email_address = '[email protected]',
      @replyto_address = '[email protected]',
      @display_name = 'SQL SERVER (IAAS-SQL16DEV)',
      @mailserver_name = 'smtp.sendgrid.net',
      @username = '[email protected]',
      @password = 'enter your unique password';
    GO
    
    -- Show the new mail accounts
    EXEC msdb.dbo.sysmail_help_account_sp;
    GO
    

    此外,您需要配置一个邮件配置文件。

    /*
       Creating a mail profile
    */
    
    -- Create a Database Mail profile
    EXEC msdb.dbo.sysmail_add_profile_sp
      @profile_name = 'prf_Default_Email',
      @description = 'Profile used for administrative mail.' ;
    GO
    
    -- Show the new mail profile
    EXEC msdb.dbo.sysmail_help_profile_sp;
    GO
    

    下一步是将电子邮件帐户链接到个人资料:

    /*
      Linking the mail profile to the account
    */
    
    -- Add the account 1 to the profile
    EXEC msdb.dbo.sysmail_add_profileaccount_sp
      @profile_name = 'prf_Default_Email',
      @account_name = 'act_Default_Email',
      @sequence_number = 1 ;
    GO
    
    -- Show the link between profile and accounts
    EXEC msdb.dbo.sysmail_help_profileaccount_sp @profile_name = 'prf_Default_Email';
    

    下一步,配置数据库邮件以授予对邮件配置文件的公共访问权限。这允许数据库用户发送邮件。

    /*
       Given public access to profile
    */
    
    -- Grant access to the profile to all users in the msdb database
    EXEC msdb.dbo.sysmail_add_principalprofile_sp
      @profile_name = 'prf_Default_Email',
      @principal_name = 'public',
      @is_default = 1 ;
    
    -- Show the new default profile
    EXEC msdb.dbo.sysmail_help_principalprofile_sp
    

    最后使用下面的代码来验证这个解决方案。

    /*
       Send test message
    */
    
    -- Plain text message
    EXEC msdb.dbo.sp_send_dbmail
      @profile_name = 'prf_Default_Email',
      @recipients = '[email protected]',
      @body = 'The stored procedure finished successfully.',
      @subject = 'Automated Success Message' ;
    GO
    
    • 4
  2. SqlWorldWide
    2019-10-14T09:40:48+08:002019-10-14T09:40:48+08:00

    是的,它具有 SMTP 服务器的一项限制。请阅读这两篇文章以解决问题。除了 SMTP 服务器,我不知道 Azure Cloud 上的本地和 SQL Server 之间有什么区别。

    在线排查 Azure图书中的出站 SMTP 连接问题

    John Doyle在 Azure 虚拟机上设置 SMTP 服务器

    • 2

相关问题

  • SQL Server - 使用聚集索引时如何存储数据页

  • 我需要为每种类型的查询使用单独的索引,还是一个多列索引可以工作?

  • 什么时候应该使用唯一约束而不是唯一索引?

  • 死锁的主要原因是什么,可以预防吗?

  • 如何确定是否需要或需要索引

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目

    • 12 个回答
  • Marko Smith

    如何让sqlplus的输出出现在一行中?

    • 3 个回答
  • Marko Smith

    选择具有最大日期或最晚日期的日期

    • 3 个回答
  • Marko Smith

    如何列出 PostgreSQL 中的所有模式?

    • 4 个回答
  • Marko Smith

    列出指定表的所有列

    • 5 个回答
  • Marko Smith

    如何在不修改我自己的 tnsnames.ora 的情况下使用 sqlplus 连接到位于另一台主机上的 Oracle 数据库

    • 4 个回答
  • Marko Smith

    你如何mysqldump特定的表?

    • 4 个回答
  • Marko Smith

    使用 psql 列出数据库权限

    • 10 个回答
  • Marko Smith

    如何从 PostgreSQL 中的选择查询中将值插入表中?

    • 4 个回答
  • Marko Smith

    如何使用 psql 列出所有数据库和表?

    • 7 个回答
  • Martin Hope
    Jin 连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目 2014-12-02 02:54:58 +0800 CST
  • Martin Hope
    Stéphane 如何列出 PostgreSQL 中的所有模式? 2013-04-16 11:19:16 +0800 CST
  • Martin Hope
    Mike Walsh 为什么事务日志不断增长或空间不足? 2012-12-05 18:11:22 +0800 CST
  • Martin Hope
    Stephane Rolland 列出指定表的所有列 2012-08-14 04:44:44 +0800 CST
  • Martin Hope
    haxney MySQL 能否合理地对数十亿行执行查询? 2012-07-03 11:36:13 +0800 CST
  • Martin Hope
    qazwsx 如何监控大型 .sql 文件的导入进度? 2012-05-03 08:54:41 +0800 CST
  • Martin Hope
    markdorison 你如何mysqldump特定的表? 2011-12-17 12:39:37 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 对 SQL 查询进行计时? 2011-06-04 02:22:54 +0800 CST
  • Martin Hope
    Jonas 如何从 PostgreSQL 中的选择查询中将值插入表中? 2011-05-28 00:33:05 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 列出所有数据库和表? 2011-02-18 00:45:49 +0800 CST

热门标签

sql-server mysql postgresql sql-server-2014 sql-server-2016 oracle sql-server-2008 database-design query-performance sql-server-2017

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve