Pull files from Azure Blob Storage using EnsLib.CloudStorage.InboundAdapter
Has anyone been able to successfully implement a business service to pull files from Azure Blob storage?
Discussion (1)0
Comments
What is the issue with it? Do you have any particular errors?
Looking for a sample Ensemble BusinessService that uses the adapter to download data. Initially I'd like to just build a passthrough service, but I would also like to create an inbound HL7 service and a Record Mapper service.
/// https://docs.intersystems.com/irisforhealth20231/csp/docbook/Doc.View.cls?KEY=EGIN_options_connectivity\/// https://docs.intersystems.com/irisforhealth20231/csp/docbook/DocBook.UI.Page.cls?KEY=ECLOUD_inbound/// https://docs.intersystems.com/irisforhealth20231/csp/documatic/%25CSP.Documatic.cls?LIBRARY=ENSLIB&CLASSNAME=EnsLib.CloudStorage.InboundAdapterClass ARTIS.Adapter.CloudStorage.PassthroughService Extends Ens.BusinessService
{
Parameter ADAPTER = "EnsLib.CloudStorage.InboundAdapter";/// Configuration item(s) to which to send file stream messagesProperty TargetConfigNames As%String(MAXLEN = 1000);Parameter SETTINGS = "TargetConfigNames:Basic:selector?multiSelect=1&context={Ens.ContextSearch/ProductionItems?targets=1&productionName=@productionId}";Parameter CONTAINERCLASS = "Ens.StreamContainer";/// Wrap the input stream object in a StreamContainer message object and send it. <p>/// https://docs.intersystems.com/irisforhealth20231/csp/docbook/DocBook.UI.Page.cls?KEY=ECLOUD_inbound#ECLOUD_inbound_bs/// based on EnsLib.File.PassthroughService but [at least initially] without archive and work folders.<p>/// We assume our InboundAdapter has the DeleteAfterDownload to prevent pulling the same over and over.
Method OnProcessInput(pInput As EnsLib.CloudStorage.InboundInput, Output pOutput As%RegisteredObject) As%Status
{
// https://docs.intersystems.com/irisforhealth20231/csp/docbook/DocBook.UI.Page.cls?KEY=ECLOUD_inbound#ECLOUD_inbound_bs#dim tContent As%GlobalBinaryStream = pInput.Content //a stream that contains the data from cloud storage#dim tMeta As%String = pInput.Meta // metadata associated with the cloud storage blob#dim tName As%String = pInput.Name // the name of cloud storage blob#dim tSC,tSC1 As%Status = $$$OK#dim tSource, iTarget, tOneTarget As%String#dim tSyncCommit As%IntegerSet tSource=$G(tName) _ $C(10)_$G(tMeta)
// Do I need to convert tContent from binary stream to character stream first?? https://docs.intersystems.com/irisforhealth20242/csp/docbook/DocBook.UI.Page.cls?KEY=RCOS_fzconvert#RCOS_fzconvert_handleSet pInput=$classmethod(..#CONTAINERCLASS,"%New",tContent)
$$$SyncCommitSet(tSyncCommit)
For iTarget=1:1:$L(..TargetConfigNames, ",") { Set tOneTarget=$ZStrip($P(..TargetConfigNames,",",iTarget),"<>W") Continue:""=tOneTarget
$$$sysTRACE("Sending input Stream "_pInput.Stream_"("_pInput.Stream.Size_")"_" from '"_tSource_"' to '"_tOneTarget_"'")
Set tSC1=..SendRequestAsync(tOneTarget,pInput) Set:$$$ISERR(tSC1) tSC=$$$ADDSC(tSC,tSC1)
}
$$$SyncCommitClear(tSyncCommit)
Quit tSC
}
/// Return an array of connections for drawing lines on the config diagramClassMethod OnGetConnections(Output pArray As%String, pItem As Ens.Config.Item)
{
Do##super(.pArray,pItem)
If pItem.GetModifiedSetting("TargetConfigNames",.tValue) {
For i=1:1:$L(tValue,",") { Set tOne=$ZStrip($P(tValue,",",i),"<>W") Continue:""=tOne Set pArray(tOne)="" }
}
}
}