Issue with FTPs on BizTalk 2013 r2

I got this error in BizTalk:

No Client Certificate matching the provided client certificate hash was found. Verify if the certificate is present in the personal store of the corresponding BizTalk host instance user account.

PLaying with the certificate store, thumbprints did not do anything. So I tried it on another dev machine and the event log showed a different error!

The adapter “FTP” raised an error message. Details “Unable to connect to FTP server “”” as user “username”. Inner Exception details: “The server name in the server certificate does not match with the name of the physical server. Make sure you provide the right server name.

Changing the server in the FTP adapter to the DNS name in the certificate did the trick! Without thumbprint the certificate is correct resolved. So when you encounter certificate error also you can check this.

Receiving file via HTTP simple script for IIS

I was working for a customer and there was a need for receiving files via HTTP and saving them to disk. A BizTalk receive location was enabled on that location and processed the file after it was stored. Normally you would make use of BTSHTTPReceive.dll and directly send it to a BizTalk location. In this case the client wanted a buffer location for the files.

I created a simple script to do just that with no editting in the iis settings. Just create a file in the iis folder with the name ReHttpsRawPost.ashx with the following code:

<%@ WebHandler Language="C#" Class="ReHttpsRawPost" %>

using System;
using System.Web;
using System.IO;
using System.Collections.Specialized;

public class ReHttpsRawPost : IHttpHandler {

public void ProcessRequest (HttpContext context)
string path = @"D:\Messages\out\interfacename";

if (!System.IO.Directory.Exists(path))

context.Response.ContentType = "text/plain";
string destionationPath = Path.Combine(path, Guid.NewGuid() + ".xml");

if (!File.Exists(destionationPath))
using (FileStream fs = File.Create(destionationPath)) { }

context.Request.SaveAs(destionationPath, false);

public bool IsReusable {
get {
return false;


Now you can you the https settings in IIS to encrypt the transfer and disable anonymous settings so posting is only allowed with username and password.

Enjoy the script, let me know if it works!


Starting all EDI batches

When you are using the EDI batching functionality for outgoing messages in the BizTalk platform, it can be an effort to start all the batching for an environment.

The batching is located in the BizTalk EDI Application:

This is included with the BizTalk server installation as an extra option. The application consist of 4 orchestrations and receive and send locations:

With this you need to configure the batching on the agreement in the party configuration. Here are a few links how to do just that:

Batching Outgoing EDI Messages
BizTalk 2010 EDI Batching Tutorial
All you need to know about Outbound EDI Batching

The only thing is that you have to start every batching from the EDI agreement party configuration. And that can be frustrating…. Especially when you have some 20 batches to be started for a release. So I created a script to do just this. Start all batching for all agreements that have batching. And here it is:

DECLARE @BatchIdNew BigInt,
@BatchName nvarchar (256),
@ReceiverPartyName nvarchar (256),
@SenderPartyName nvarchar (256),
@AgreementName nvarchar (256);

SELECT Id, Name,
(SELECT [Name] FROM [tpm].[Partner] WHERE [PartnerId]=(SELECT [PartnerId] FROM [tpm].[BusinessProfile] WHERE [ProfileId]=(SELECT [ProfileId] FROM [tpm].[BusinessIdentity] WHERE Id=(SELECT [ReceiverId] FROM [tpm].[OnewayAgreement] WHERE Id=BatchDescription.[OnewayAgreementId])))) AS ReceiverName,
(SELECT [Name] FROM [tpm].[Partner] WHERE [PartnerId]=(SELECT [PartnerId] FROM [tpm].[BusinessProfile] WHERE [ProfileId]=(SELECT [ProfileId] FROM [tpm].[BusinessIdentity] WHERE Id=(SELECT [SenderId] FROM [tpm].[OnewayAgreement] WHERE Id=BatchDescription.[OnewayAgreementId])))) AS SenderName,
(SELECT [Name] FROM [tpm].[Agreement] WHERE [SenderOnewayAgreementId]=BatchDescription.[OnewayAgreementId]) AS AgreementName
FROM [BizTalkMgmtDb].[tpm].BatchDescription
FETCH NEXT FROM c into @BatchIdNew, @BatchName, @ReceiverPartyName, @SenderPartyName, @AgreementName;


EXEC [BizTalkMgmtDb].dbo.edi_CreateControlMessage_Activate @BatchId=@BatchIdNew,@EdiMessageType=1,
FETCH NEXT FROM c into @BatchIdNew, @BatchName, @ReceiverPartyName, @SenderPartyName, @AgreementName;


You will run this on the management database of BizTalk, and all your batching will be started. Good luck!

Get size of all tables in database


    t.NAME AS TableName,
    s.Name AS SchemaName,
    p.rows AS RowCounts,
    SUM(a.total_pages) * 8 AS TotalSpaceKB, 
    SUM(a.used_pages) * 8 AS UsedSpaceKB, 
    (SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB
    sys.tables t
    sys.indexes i ON t.OBJECT_ID = i.object_id
    sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
    sys.allocation_units a ON p.partition_id = a.container_id
    sys.schemas s ON t.schema_id = s.schema_id
    t.NAME NOT LIKE 'dt%' 
    AND t.is_ms_shipped = 0
    AND i.OBJECT_ID > 255 
    t.Name, s.Name, p.Rows


Got this query from here.