Skip to content

Commit 56cadc8

Browse files
1741262 validation: code-block-indented
1 parent a842dc2 commit 56cadc8

6 files changed

+68
-9
lines changed

articles/azure-monitor/app/asp-net-trace-logs.md

+15-7
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,15 @@ For examples of using the Application Insights ILogger implementation with conso
6969
## Insert diagnostic log calls
7070
If you use System.Diagnostics.Trace, a typical call would be:
7171

72-
System.Diagnostics.Trace.TraceWarning("Slow response - database01");
72+
```csharp
73+
System.Diagnostics.Trace.TraceWarning("Slow response - database01");
74+
```
7375

7476
If you prefer log4net or NLog, use:
7577

78+
```csharp
7679
logger.Warn("Slow response - database01");
80+
```
7781

7882
## Use EventSource events
7983
You can configure [System.Diagnostics.Tracing.EventSource](https://msdn.microsoft.com/library/system.diagnostics.tracing.eventsource.aspx) events to be sent to Application Insights as traces. First, install the `Microsoft.ApplicationInsights.EventSourceListener` NuGet package. Then edit the `TelemetryModules` section of the [ApplicationInsights.config](../../azure-monitor/app/configuration-with-applicationinsights-config.md) file.
@@ -129,17 +133,21 @@ You can call the Application Insights trace API directly. The logging adapters u
129133

130134
For example:
131135

132-
var telemetry = new Microsoft.ApplicationInsights.TelemetryClient();
133-
telemetry.TrackTrace("Slow response - database01");
136+
```csharp
137+
var telemetry = new Microsoft.ApplicationInsights.TelemetryClient();
138+
telemetry.TrackTrace("Slow response - database01");
139+
```
134140

135141
An advantage of TrackTrace is that you can put relatively long data in the message. For example, you can encode POST data there.
136142

137143
You can also add a severity level to your message. And, like other telemetry, you can add property values to help filter or search for different sets of traces. For example:
138144

139-
var telemetry = new Microsoft.ApplicationInsights.TelemetryClient();
140-
telemetry.TrackTrace("Slow database response",
141-
SeverityLevel.Warning,
142-
new Dictionary<string,string> { {"database", db.ID} });
145+
```csharp
146+
var telemetry = new Microsoft.ApplicationInsights.TelemetryClient();
147+
telemetry.TrackTrace("Slow database response",
148+
SeverityLevel.Warning,
149+
new Dictionary<string,string> { {"database", db.ID} });
150+
```
143151

144152
This would enable you to easily filter out in [Search][diagnostic] all the messages of a particular severity level that relate to a particular database.
145153

articles/azure-sql/database/elastic-query-horizontal-partitioning.md

+14
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ These statements create the metadata representation of your sharded data tier in
4343

4444
The credential is used by the elastic query to connect to your remote databases.
4545

46+
```sql
4647
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'password';
4748
CREATE DATABASE SCOPED CREDENTIAL <credential_name> WITH IDENTITY = '<username>',
4849
SECRET = '<password>'
4950
[;]
51+
```
5052

5153
> [!NOTE]
5254
> Make sure that the *"\<username\>"* does not include any *"\@servername"* suffix.
@@ -55,6 +57,7 @@ The credential is used by the elastic query to connect to your remote databases.
5557

5658
Syntax:
5759

60+
```sql
5861
<External_Data_Source> ::=
5962
CREATE EXTERNAL DATA SOURCE <data_source_name> WITH
6063
(TYPE = SHARD_MAP_MANAGER,
@@ -63,9 +66,11 @@ Syntax:
6366
CREDENTIAL = <credential_name>,
6467
SHARD_MAP_NAME = ‘<shardmapname>’
6568
) [;]
69+
```
6670

6771
### Example
6872

73+
```sql
6974
CREATE EXTERNAL DATA SOURCE MyExtSrc
7075
WITH
7176
(
@@ -75,10 +80,13 @@ Syntax:
7580
CREDENTIAL= SMMUser,
7681
SHARD_MAP_NAME='ShardMap'
7782
);
83+
```
7884

7985
Retrieve the list of current external data sources:
8086

87+
```sql
8188
select * from sys.external_data_sources;
89+
```
8290

8391
The external data source references your shard map. An elastic query then uses the external data source and the underlying shard map to enumerate the databases that participate in the data tier.
8492
The same credentials are used to read the shard map and to access the data on the shards during the processing of an elastic query.
@@ -87,6 +95,7 @@ The same credentials are used to read the shard map and to access the data on th
8795

8896
Syntax:
8997

98+
```sql
9099
CREATE EXTERNAL TABLE [ database_name . [ schema_name ] . | schema_name. ] table_name
91100
( { <column_definition> } [ ,...n ])
92101
{ WITH ( <sharded_external_table_options> ) }
@@ -97,9 +106,11 @@ Syntax:
97106
[ SCHEMA_NAME = N'nonescaped_schema_name',]
98107
[ OBJECT_NAME = N'nonescaped_object_name',]
99108
DISTRIBUTION = SHARDED(<sharding_column_name>) | REPLICATED |ROUND_ROBIN
109+
```
100110

101111
**Example**
102112

113+
```sql
103114
CREATE EXTERNAL TABLE [dbo].[order_line](
104115
[ol_o_id] int NOT NULL,
105116
[ol_d_id] tinyint NOT NULL,
@@ -120,14 +131,17 @@ Syntax:
120131
OBJECT_NAME = 'order_details',
121132
DISTRIBUTION=SHARDED(ol_w_id)
122133
);
134+
```
123135

124136
Retrieve the list of external tables from the current database:
125137

126138
SELECT * from sys.external_tables;
127139

128140
To drop external tables:
129141

142+
```sql
130143
DROP EXTERNAL TABLE [ database_name . [ schema_name ] . | schema_name. ] table_name[;]
144+
```
131145

132146
### Remarks
133147

articles/azure-sql/database/elastic-scale-split-merge-security-configuration.md

+23-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ If those options are not available, you can generate **self-signed certificates*
4141

4242
If installed, go to:
4343

44-
%ProgramFiles(x86)%\Windows Kits\x.y\bin\x86
44+
```console
45+
%ProgramFiles(x86)%\Windows Kits\x.y\bin\x86
46+
```
47+
4548
* Get the WDK from [Windows 8.1: Download kits and tools](https://msdn.microsoft.com/windows/hardware/gg454513#drivers)
4649

4750
## To configure the TLS/SSL certificate
@@ -187,12 +190,14 @@ This topic is for reference only. Follow the configuration steps outlined in:
187190
## Create a self-signed certificate
188191
Execute:
189192

193+
```console
190194
makecert ^
191195
-n "CN=myservice.cloudapp.net" ^
192196
-e MM/DD/YYYY ^
193197
-r -cy end -sky exchange -eku "1.3.6.1.5.5.7.3.1" ^
194198
-a sha256 -len 2048 ^
195199
-sv MySSL.pvk MySSL.cer
200+
```
196201

197202
To customize:
198203

@@ -203,7 +208,9 @@ To customize:
203208
## Create PFX file for self-signed TLS/SSL certificate
204209
Execute:
205210

206-
pvk2pfx -pvk MySSL.pvk -spc MySSL.cer
211+
```console
212+
pvk2pfx -pvk MySSL.pvk -spc MySSL.cer
213+
```
207214

208215
Enter password and then export certificate with these options:
209216

@@ -226,7 +233,9 @@ Upload certificate with the existing or generated .PFX file with the TLS key pai
226233
## Update TLS/SSL certificate in service configuration file
227234
Update the thumbprint value of the following setting in the service configuration file with the thumbprint of the certificate uploaded to the cloud service:
228235

236+
```console
229237
<Certificate name="SSL" thumbprint="" thumbprintAlgorithm="sha1" />
238+
```
230239

231240
## Import TLS/SSL certification authority
232241
Follow these steps in all account/machine that will communicate with the service:
@@ -254,13 +263,15 @@ Then, copy the same thumbprint as the TLS/SSL certificate in the CA certificate
254263
## Create a self-signed certification authority
255264
Execute the following steps to create a self-signed certificate to act as a Certification Authority:
256265

266+
```console
257267
makecert ^
258268
-n "CN=MyCA" ^
259269
-e MM/DD/YYYY ^
260270
-r -cy authority -h 1 ^
261271
-a sha256 -len 2048 ^
262272
-sr localmachine -ss my ^
263273
MyCA.cer
274+
```
264275

265276
To customize it
266277

@@ -307,13 +318,15 @@ Each individual authorized to access the service should have a client certificat
307318

308319
The following steps must be executed in the same machine where the self-signed CA certificate was generated and stored:
309320

321+
```console
310322
makecert ^
311323
-n "CN=My ID" ^
312324
-e MM/DD/YYYY ^
313325
-cy end -sky exchange -eku "1.3.6.1.5.5.7.3.2" ^
314326
-a sha256 -len 2048 ^
315327
-in "MyCA" -ir localmachine -is my ^
316328
-sv MyID.pvk MyID.cer
329+
```
317330

318331
Customizing:
319332

@@ -326,11 +339,15 @@ This command will prompt for a password to be created and then used once. Use a
326339
## Create PFX files for client certificates
327340
For each generated client certificate, execute:
328341

342+
```console
329343
pvk2pfx -pvk MyID.pvk -spc MyID.cer
344+
```
330345

331346
Customizing:
332347

348+
```console
333349
MyID.pvk and MyID.cer with the filename for the client certificate
350+
```
334351

335352
Enter password and then export certificate with these options:
336353

@@ -375,11 +392,15 @@ The default setting does not check with the Certification Authority for client c
375392
## Create PFX file for self-signed encryption certificates
376393
For an encryption certificate, execute:
377394

395+
```console
378396
pvk2pfx -pvk MyID.pvk -spc MyID.cer
397+
```
379398

380399
Customizing:
381400

401+
```console
382402
MyID.pvk and MyID.cer with the filename for the encryption certificate
403+
```
383404

384405
Enter password and then export certificate with these options:
385406

articles/azure-sql/database/elastic-scale-upgrade-client-library.md

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Performing these steps in order ensures that old versions of the client library
5353

5454
Alternatively, create a Visual Studio application that opens your ShardMapManager, iterates over all shards, and performs the metadata upgrade by calling the methods [UpgradeLocalStore](https://docs.microsoft.com/dotnet/api/microsoft.azure.sqldatabase.elasticscale.shardmanagement.shardmapmanager.upgradelocalstore) and [UpgradeGlobalStore](https://docs.microsoft.com/dotnet/api/microsoft.azure.sqldatabase.elasticscale.shardmanagement.shardmapmanager.upgradeglobalstore) as in this example:
5555

56+
```cssharp
5657
ShardMapManager smm =
5758
ShardMapManagerFactory.GetSqlShardMapManager
5859
(connStr, ShardMapManagerLoadPolicy.Lazy);
@@ -63,6 +64,7 @@ Alternatively, create a Visual Studio application that opens your ShardMapManage
6364
{
6465
smm.UpgradeLocalStore(loc);
6566
}
67+
```
6668

6769
These techniques for metadata upgrades can be applied multiple times without harm. For example, if an older client version inadvertently creates a shard after you have already updated, you can run upgrade again across all shards to ensure that the latest metadata version is present throughout your infrastructure.
6870

articles/azure-sql/database/elastic-scale-working-with-dapper.md

+8
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ The shard map object creates a connection to the shard that holds the shardlet f
8181

8282
Queries work very much the same way - you first open the connection using [OpenConnectionForKey](https://msdn.microsoft.com/library/azure/dn807226.aspx) from the client API. Then you use the regular Dapper extension methods to map the results of your SQL query into .NET objects:
8383

84+
```csharp
8485
using (SqlConnection sqlconn = shardingLayer.ShardMap.OpenConnectionForKey(
8586
key: tenantId1,
8687
connectionString: connStrBldr.ConnectionString,
@@ -98,6 +99,7 @@ Queries work very much the same way - you first open the connection using [OpenC
9899
Console.WriteLine(item.Name);
99100
}
100101
}
102+
```
101103

102104
Note that the **using** block with the DDR connection scopes all database operations within the block to the one shard where tenantId1 is kept. The query only returns blogs stored on the current shard, but not the ones stored on any other shards.
103105

@@ -106,6 +108,7 @@ Dapper comes with an ecosystem of additional extensions that can provide further
106108

107109
Using DapperExtensions in your application does not change how database connections are created and managed. It is still the application’s responsibility to open connections, and regular SQL Client connection objects are expected by the extension methods. We can rely on the [OpenConnectionForKey](https://msdn.microsoft.com/library/azure/dn807226.aspx) as outlined above. As the following code samples show, the only change is that you no longer have to write the T-SQL statements:
108110

111+
```csharp
109112
using (SqlConnection sqlconn = shardingLayer.ShardMap.OpenConnectionForKey(
110113
key: tenantId2,
111114
connectionString: connStrBldr.ConnectionString,
@@ -114,9 +117,11 @@ Using DapperExtensions in your application does not change how database connecti
114117
var blog = new Blog { Name = name2 };
115118
sqlconn.Insert(blog);
116119
}
120+
```
117121

118122
And here is the code sample for the query:
119123

124+
```csharp
120125
using (SqlConnection sqlconn = shardingLayer.ShardMap.OpenConnectionForKey(
121126
key: tenantId2,
122127
connectionString: connStrBldr.ConnectionString,
@@ -130,12 +135,14 @@ And here is the code sample for the query:
130135
Console.WriteLine(item.Name);
131136
}
132137
}
138+
```
133139

134140
### Handling transient faults
135141
The Microsoft Patterns & Practices team published the [Transient Fault Handling Application Block](https://msdn.microsoft.com/library/hh680934.aspx) to help application developers mitigate common transient fault conditions encountered when running in the cloud. For more information, see [Perseverance, Secret of All Triumphs: Using the Transient Fault Handling Application Block](https://msdn.microsoft.com/library/dn440719.aspx).
136142

137143
The code sample relies on the transient fault library to protect against transient faults.
138144

145+
```csharp
139146
SqlDatabaseUtils.SqlRetryPolicy.ExecuteAction(() =>
140147
{
141148
using (SqlConnection sqlconn =
@@ -145,6 +152,7 @@ The code sample relies on the transient fault library to protect against transie
145152
sqlconn.Insert(blog);
146153
}
147154
});
155+
```
148156

149157
**SqlDatabaseUtils.SqlRetryPolicy** in the code above is defined as a **SqlDatabaseTransientErrorDetectionStrategy** with a retry count of 10, and 5 seconds wait time between retries. If you are using transactions, make sure that your retry scope goes back to the beginning of the transaction in the case of a transient fault.
150158

articles/azure-sql/database/elastic-transactions-overview.md

+6
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Remember that elastic database transactions don't require installing MSDTC. Inst
4444

4545
The following sample code uses the familiar programming experience with .NET System.Transactions. The TransactionScope class establishes an ambient transaction in .NET. (An “ambient transaction” is one that lives in the current thread.) All connections opened within the TransactionScope participate in the transaction. If different databases participate, the transaction is automatically elevated to a distributed transaction. The outcome of the transaction is controlled by setting the scope to complete to indicate a commit.
4646

47+
```csharp
4748
using (var scope = new TransactionScope())
4849
{
4950
using (var conn1 = new SqlConnection(connStrDb1))
@@ -64,12 +65,14 @@ The following sample code uses the familiar programming experience with .NET Sys
6465

6566
scope.Complete();
6667
}
68+
```
6769

6870
### Sharded database applications
6971

7072
Elastic database transactions for SQL Database also support coordinating distributed transactions where you use the OpenConnectionForKey method of the elastic database client library to open connections for a scaled out data tier. Consider cases where you need to guarantee transactional consistency for changes across several different sharding key values. Connections to the shards hosting the different sharding key values are brokered using OpenConnectionForKey. In the general case, the connections can be to different shards such that ensuring transactional guarantees requires a distributed transaction.
7173
The following code sample illustrates this approach. It assumes that a variable called shardmap is used to represent a shard map from the elastic database client library:
7274

75+
```csharp
7376
using (var scope = new TransactionScope())
7477
{
7578
using (var conn1 = shardmap.OpenConnectionForKey(tenantId1, credentialsStr))
@@ -90,6 +93,7 @@ The following code sample illustrates this approach. It assumes that a variable
9093

9194
scope.Complete();
9295
}
96+
```
9397

9498
## .NET installation for Azure Cloud Services
9599

@@ -99,6 +103,7 @@ For Azure App Service, upgrades to the guest OS are currently not supported. For
99103

100104
Note that the installer for .NET 4.6.1 may require more temporary storage during the bootstrapping process on Azure cloud services than the installer for .NET 4.6. To ensure a successful installation, you need to increase temporary storage for your Azure cloud service in your ServiceDefinition.csdef file in the LocalResources section and the environment settings of your startup task, as shown in the following sample:
101105

106+
```xml
102107
<LocalResources>
103108
...
104109
<LocalStorage name="TEMP" sizeInMB="5000" cleanOnRoleRecycle="false" />
@@ -117,6 +122,7 @@ Note that the installer for .NET 4.6.1 may require more temporary storage during
117122
</Environment>
118123
</Task>
119124
</Startup>
125+
```
120126

121127
## Transactions across multiple servers
122128

0 commit comments

Comments
 (0)