The instrumentation monitors your app and directs the telemetry data to an Azure Application Insights Resource using a unique GUID that we refer to as an Instrumentation Key. You can instrument not only the web service application, but also any background components, and the JavaScript in the web pages themselves. The application and its components can run anywhere - it doesn’t have to be hosted in Azure. 使用Guid作为Instrumentation Key(ikey)标识作为监视器的Azure Insights资源。 监测web服务应用或后台组件亦或页面js 这些应用或组件、命令不必托管在Azure中
创建Azure App Insights资源
Azure Portal -> Application Insights -> Create
添加Javascript SDK
1
npm i --save @microsoft/applicationinsights-web
使用ikey或连接字符串创建客户端instance
1 2 3 4 5 6 7 8 9
import { ApplicationInsights } from '@microsoft/applicationinsights-web'
const appInsights = new ApplicationInsights({ config: { instrumentationKey: 'YOUR_INSTRUMENTATION_KEY_GOES_HERE' /* 使用ikey */ /* 或使用 connectionString: 'YOUR_CONNECTION_STRING_GOES_HERE' */ /* ...Other Configuration Options... */ } }); appInsights.loadAppInsights(); appInsights.trackPageView(); // Manually call trackPageView to establish the current user/session/pageview
class Factory { public Computer produceComputer(String type) { Computer c = null; if(type.equals("macbook")){ c = new Macbook(); }else if(type.equals("surface")){ c = new Surface(); } return c; } }
抽象出produce接口
1 2 3 4 5 6 7 8 9 10 11 12 13
interface Factory { public Computer produceComputer(); } class AppleFactory implements Factory { public Computer produceComputer() { return new Macbook(); } } class MSFactory implements Factory { public Computer produceComputer() { return new Surface(); } }
USE master; GO CREATE LOGIN login_test WITH PASSWORD = N'3KHJ6dhx(0xVYsdf' MUST_CHANGE, CHECK_EXPIRATION = ON; GO GRANT VIEW SERVER STATE TO login_test; GO CREATE TRIGGER connection_limit_trigger ON ALL SERVER WITH EXECUTE AS N'login_test' FOR LOGON AS BEGIN IF ORIGINAL_LOGIN()= N'login_test' AND (SELECT COUNT(*) FROM sys.dm_exec_sessions WHERE is_user_process = 1 AND original_login_name = N'login_test') > 3 ROLLBACK; END;
可知登录触发器在身份认证之后,建立会话之前触发 多个触发器的顺序,即支持指定the first和the last 见Microsoft Docs
DDL
data define language 数据定义语言 即在使用会改变数据库数据结构的语句时触发,如CREATE、ALTER、DROP、GRANT、DENY、REVOKE 或 UPDATE STATISTICS 开头的 Transact-SQL 语句 场景
防止对数据库架构进行某些更改。
希望数据库中发生某种情况以响应数据库架构的更改。
记录数据库架构的更改或事件。
DML
data manipulation language (DML) 数据操作语言 INSERT、UPDATE 或 DELETE 语句 after 触发器
1 2 3 4 5 6 7 8 9 10 11 12 13 14
CREATE TRIGGER schemaA.SyncData ON schemaA.TableA AFTER INSERT AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements.
-- Insert statements for trigger here insert into schemaB.TableB(Name,TrustedId,EmailAddress,Logo,Type,Enable,RecordStatus,RecordCreated,RecordLastUpdated) select name,record_pk,email,logo,'1',0,0,SYSDATETIME(),SYSDATETIME() from schemaA.TableA SET NOCOUNT ON; END GO