New post

Pesquisar

Digest
· Aug 19, 2024

InterSystems Developers Publications, Week August 12 - 18, 2024, Digest

Articles
Announcements
Questions
#InterSystems IRIS
#Health Connect
#Ensemble
#InterSystems IRIS for Health
#Caché
August 12 - 18, 2024Week at a GlanceInterSystems Developer Community
Article
· Aug 19, 2024 4m read

Accessing Azure Blob Storage

Accessing an Azure cloud storage to upload/download blobs is quite easy using the designated %Net.Cloud.Storage.Client class API methods, or using the EnsLib.CloudStorage.* inbound/outbound adaptors.

Note that you'll need to have the %JavaServer External Language Server up and running to use the cloud storage API or adaptors, since they both use the PEX framework using the Java Server.

Here is a quick summary:

Azure Blob Storage is accessed using a connection string that looks similar to this:

DefaultEndpointsProtocol=https;AccountName=abcdefscleanisr;AccountKey=n3mWskdjgfhklsghdfjaskhgkjdfizqMWJ5X2L4JpqeEJk/FuEnw0rPI6E/rULPn0V5BWgFw+AStRJZlYQ==;EndpointSuffix=core.windows.net

Break it into lines with ";" as the delimiter and save it as a text file:

DefaultEndpointsProtocol=https;
AccountName=abcdefscleanisr;
AccountKey=n3mWskdjgfhklsghdfjaskhgkjdfizqMWJ5X2L4JpqeEJk/FuEnw0rPI6E/rULPn0V5BWgFw+AStRJZlYQ==;
EndpointSuffix=core.windows.net

For this example I will name this file "MyAzureStorage.txt".

Now let's activate the API:

set file="C:\Storage\MyAzureStorage.txt"
set endpoint="abcdefscleanisr.privatelink.blob.core.windows.net"
set tStatus=""

In the CreateClient API method, the second parameter is the cloud provider:

  • 0 - Amazon S3
  • 1 - Azure Blob
  • 2 - Google Cloud Storage
SET myClient = ##CLASS(%Net.Cloud.Storage.Client).CreateClient(,1,file,0,.tStatus,endpoint)

Once the client has been established (tStatus=1), you can run any of the client's methods:

 

In Azure Blob Storage,  a Bucket is a Container.

So for example, to get the list of Azure containers, run the ListBuckets method:

set list=myClient.ListBuckets()

for i=1:1:list.Count() {write list.GetAt(i).name,!}

clean
dirty

Once you have a container name (let's take the "clean" container as an example), you can get the list of blobs in it:
 

set list=myClient.ListBlobs("clean")

for i=1:1:list.Count() {write list.GetAt(i).name,!}

4caa6f29-e9e6-4cde-9112-65ec28d4eded.jpeg
2374233-e9e6-4cde-9112-65ec28d4eded.jpeg
3klfd3lld-e9e6-4cde-9112-65ec28d4eded.jpeg
4caa6f29-e9e6-87ry-9112-65ec28d4eded.jpeg

The CloudStorage outbound adaptor has fewer options - its methods include only the following:

  • UploadBlobFromString(bucketName,blobName,content)
  • UploadBlobFromStream(bucketName,blobName,content)
  • UploadBlobFromFile(bucketName,blobName,filePath)
  • DeleteBlob(bucketName,blobName)

Here are the settings for configuring a business operation using the EnsLib.CloudStorage.OutboundAdapter with Azure Blob Storage. The Storage Region parameter is not relevant for Azure Blob Storage.

All other parameters are relevant the same as when we were using the CreateClient method:

The ContainerName parameter is not part of the adaptor's parameters - it is not needed to create the client (the CreateClient method does not use it).

However, all the other adaptor methods listed above do need to specify to which bucket/container should the blob be loaded, it makes sense to add it as a parameter as part of the settings:

Class Sasa.BO.Storage Extends Ens.BusinessOperation
{ 
Parameter ADAPTER = "EnsLib.CloudStorage.OutboundAdapter"; 
Property Adapter As EnsLib.CloudStorage.OutboundAdapter; 
Parameter INVOCATION = "Queue"; 
/// Bucket name(Amazon) = Container name(Azure)
Property ContainerName As %String(MAXLEN = 1000); 
Parameter SETTINGS = "ContainerName:Cloud Storage"; 
Method CreateFile(pRequest As Cloud.RES.REST, Output pResponse As Cloud.RES.REST) As %Status
{
    #dim tException As %Exception.SystemException
    Set tStatus = $$$OK
    set pResponse=##class(Cloud.RES.REST).%New() 
    Try {
        Set tStatus = ..Adapter.DeleteBlob(..ContainerName, pRequest.FileName)
        Set tStatus = ..Adapter.UploadBlobFromStream(..ContainerName, pRequest.FileName, pRequest.FileData)   
        if $$$ISERR(tStatus) {
            set pResponse.Success = 0
            set pResponse.ErrorMessage = $system.Status.GetErrorText(tStatus)
        }
    } 
    Catch tException {
        Set tStatus = tException.AsStatus()
        set pResponse.Success=0
        set pResponse.ErrorMessage=$system.Status.GetErrorText(tStatus)
    }
    Quit $$$OK
}

Hope that will help you start using the cloud adaptor with Azure.

Keren.

Discussion (0)0
Log in or sign up to continue
Question
· Aug 19, 2024

Question about PKI Configuration

Hello everyone,

I'm currently working on getting familiar with OAuth2, following this article. Since Part 2 involves using PKI, I decided to implement it as outlined in the article. However, I've run into an issue that I can't seem to resolve, and my searches on Google haven't yielded any useful results.

Here's a brief overview of what I've done so far:

Configuring the PKI Server:

  • Navigated to: System Administration > Security > Public Key Infrastructure > Configure Local Certificate Authority Server.
  • Filled in all the required fields and saved the configuration.

As far as I can tell, this step was successful. The following three files were generated, and the message displayed was:

"Certificate Authority server successfully configured. Using existing files: D:\CacheSys\mgr\root_ca.cer, .key, and .srl."

Configuring the PKI Client:

  • Navigated to: System Administration > Security > Public Key Infrastructure > Configure Local Certificate Authority Client.
  • Again, I filled in all the necessary fields and saved the configuration.

 

This also seemed to work fine. The message after saving was:

"Certificate Authority client successfully configured."

Submitting a Certificate Signing Request:

  • Navigated to: System Administration > Security > Public Key Infrastructure > Submit Certificate Signing Request to Certificate Authority Server.
  • Filled in all the required fields and saved the configuration.

However, now I'm seeing the following error message:

"ERROR #5002: ObjectScript Error: <WRITE>Send+122^%Net.HttpRequest.1"

 

The auth.csr and auth.key were nevertheless created.

I’m not sure how to interpret this error message. If anyone has any insight into what might be missing or where the problem lies, I would greatly appreciate your help.

maybe also important:

Below are the SSL settings for the CA Test Server:

 

Thank you in advance for your assistance.

Best regards,
Daniel Goerke

1 Comment
Discussion (1)2
Log in or sign up to continue
Announcement
· Aug 19, 2024

Ganadores del Concurso de Python

Hola Comunidad:

¡Es hora de anunciar los ganadores del Concurso de Python

Gracias a todos nuestros increíbles participantes que presentaron 9 aplicaciones🔥 


Nominación de expertos

🥇 1er lugar $5,000 para sqlzilla aplicación presentada por @Henry Pereira, @José Pereira, @Henrique Dias

🥈 2do lugar y $3,000 para iris-RAG-Gen aplicación presentada por @Muhammad Waseem

🥉 3er lugar $1,500 para sheltershare aplicación presentada por @Zeljko Sucic, @Damir Miklos

🏅 4to lugar $750 para irislab aplicación presentada por @Dmitry Maslennikov

🏅 5to lugar $500 para iris-email-analyzer-app aplicación presentada por @Eric Mariasis

🌟 $100 para IRIS RAG App aplicación presentada por @Alex Alcivar

🌟 $100 para IRIS-production-chat-robot aplicación presentada por @Ste Sharma 

🌟 $100 para ServiceInspection aplicación presentada por @Wolis Oliavr

🌟 $100 para iris-errors-analysis-graph aplicación presentada por @Davi Massaru Teixeira Muta, @Lucas Fernandes

Nominaciones de la Comunidad

🥇 1er lugar y $1,000 para sqlzilla aplicación presentada por @Henry Pereira, @José Pereira, @Henrique Dias

🥈 2do lugar y $750 para ServiceInspection aplicación presentada por @Wolis Oliavr

🥉 3er lugar y $500 para iris-RAG-Gen aplicación presentada por @Muhammad Waseem

🏅 4to lugar $300 para IRIS-production-chat-robot aplicación presentada por @Ste Sharma

🏅 5to lugar $200 para sheltershare aplicación presentada por @Zeljko Sucic, @Damir Miklos 

¡Nuestra más sincera enhorabuena a todos los participantes y ganadores!

Únete y diviértete la próxima vez ;)

Discussion (0)1
Log in or sign up to continue