Code Monkey home page Code Monkey logo

mipsdk-file-dotnet's Introduction

page_type languages products description urlFragment
sample
csharp
m365
office-365
This sample application demonstrates using the Microsoft Information Protection SDK .NET wrapper to label and read a label from a file.
MipSDK-File-Dotnet

MIP SDK .NET 6.0 Sample

This Microsoft Information Protection File SDK sample can run on Windows, or Ubuntu 18.04/20.04. It demonstrates initializing the MIP SDK and labeling a file.

.NET 6.0 or later is required to run the sample: https://dotnet.microsoft.com/en-us/download/dotnet/6.0

Ubuntu

If you're running on Ubuntu, follow these steps to install the necessary dependencies.

Install the MIP SDK dependencies on Ubuntu

sudo apt-get install scons libgsf-1-dev libssl-dev libsecret-1-dev freeglut3-dev libcpprest-dev libcurl3-dev uuid-dev

Install the Microsoft Authentication Library dependency

MSAL on Ubuntu, when authentication in a public client application, will use a browser to perform authentication. This requires the xdg-utils package. This is included only for demonstration and not required for other auth patterns.

sudo apt-get install xdg-utils

Windows

Running on Windows requires that the Visual C++ Runtime redistributable is installed.

Required NuGet Packages

In the project directory, add the required packages by running:

dotnet add package Microsoft.Extensions.Configuration
dotnet add package Microsoft.Extensions.Configuration.FileExtensions
dotnet add package Microsoft.Extensions.Configuration.Json
dotnet add package Microsoft.Extensions.DependencyInjection
dotnet add package microsoft.identity.client

If running on Ubuntu 20.04, install the Ubuntu 20.04 package.

# Ubuntu 20.04
dotnet add package Microsoft.InformationProtection.File.Ubuntu2004

If running on Ubuntu 22.04, install the Ubuntu 22.04 package.

# Ubuntu 22.04
dotnet add package Microsoft.InformationProtection.File.Ubuntu2204

If running on Windows, install the base MIP SDK package.

# Windows Only
dotnet add package Microsoft.InformationProtection.File

Update appsettings.json

Register an application in Azure Active Directory. Once complete, populate the appsettings.json file with details from the application registration: clientId and tenantId. Change ida:IsMultiTenantApp depending upon the type of application you've registered.

Build the project and run

From the /src directory, run the following to build:

dotnet build --output ../bin/Debug

The application will output to mip-filesdk-dotnet/bin/Debug/net6.0. Run the app by executing ./mipsdk.exe or ./mipsdk

mipsdk-file-dotnet's People

Contributors

microsoft-github-operations[bot] avatar microsoftopensource avatar tommoser avatar zhang-yangchen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mipsdk-file-dotnet's Issues

Support for (Docker) Alpine Images

I get various errors attempting to build a docker image using the dotnet6-alpine image, due to package dependencies not being available via the apk package manager.

This issue is for a: (mark with an x)

- [x ] bug report -> please search issues before submitting
- [ ] feature request
- [x ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

dockerfile
RUN apk update && apk add libgsf-1-dev libssl-dev libsecret-1-dev freeglut3-dev libcpprest-dev libcurl3-dev uuid-dev

Any log messages given by the failure

#6 [base 2/3] RUN apk update && apk add libgsf-1-dev libssl-dev libsecret-1-dev freeglut3-dev libcpprest-dev libcurl3-dev uuid-dev
#6 sha256:23cd6bd18f818a437a6ae03eff1a1d1b5c9a9f407a3eb0d1ae8c0b3f942abe22
#6 0.391 fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/main/x86_64/APKINDEX.tar.gz
#6 1.056 fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/community/x86_64/APKINDEX.tar.gz
#6 1.885 v3.17.3-26-ge88dd296088 [https://dl-cdn.alpinelinux.org/alpine/v3.17/main]
#6 1.885 v3.17.3-31-g94892a46a98 [https://dl-cdn.alpinelinux.org/alpine/v3.17/community]
#6 1.885 OK: 17818 distinct packages available
#6 2.248 ERROR: unable to select packages:
#6 2.248 freeglut3-dev (no such package):
#6 2.283 required by: world[freeglut3-dev]
#6 2.283 libcpprest-dev (no such package):
#6 2.283 required by: world[libcpprest-dev]
#6 2.283 libcurl3-dev (no such package):
#6 2.283 required by: world[libcurl3-dev]
#6 2.283 libgsf-1-dev (no such package):
#6 2.283 required by: world[libgsf-1-dev]
#6 2.283 libsecret-1-dev (no such package):
#6 2.283 required by: world[libsecret-1-dev]
#6 2.283 libssl-dev (no such package):
#6 2.283 required by: world[libssl-dev]
#6 2.283 uuid-dev (no such package):
#6 2.283 required by: world[uuid-dev]
#6 ERROR: executor failed running [/bin/sh -c apk update && apk add libgsf-1-dev libssl-dev libsecret-1-dev freeglut3-dev libcpprest-dev libcurl3-dev uuid-dev]: exit code: 7


[base 2/3] RUN apk update && apk add libgsf-1-dev libssl-dev libsecret-1-dev freeglut3-dev libcpprest-dev libcurl3-dev uuid-dev:


executor failed running [/bin/sh -c apk update && apk add libgsf-1-dev libssl-dev libsecret-1-dev freeglut3-dev libcpprest-dev libcurl3-dev uuid-dev]: exit code: 7

Expected/desired behavior

The container image should be able to build as the base Alpine image is a standard Microsoft base image for running dotnet code. The Alpine base image is preferred over the Ubuntu/Debian image (mcr.microsoft.com/dotnet/aspnet:6.0) as it is more secure.

OS and Version?

Linux docker image (mcr.microsoft.com/dotnet/aspnet:6.0-alpine)

Unable to run the example in Ubuntu 20.04 - LoadLibrary failed for libmip_dotnet.so

I always get this error when trying to run ./mipsdk under Ubuntu 20.04.

Unhandled exception. System.ComponentModel.Win32Exception (0x80004005): LoadLibrary failed for: [/home/<sanitized>/mip-filesdk-dotnet-core/bin/Debug/libmip_dotnet.so]
   at Microsoft.InformationProtection.Utils.SafeNativeMethods.LoadLibrary(String dllToLoad)
   at Microsoft.InformationProtection.Utils.Loader.LoadDlls(String dllFolder, String dllName, String[] dllDependencies)
   at Microsoft.InformationProtection.MIP.Initialize(MipComponent mipComponent, String path)
   at Microsoft.InformationProtection.MIP.CreateMipContext(MipConfiguration mipConfiguration)
   at mipsdk.Action..ctor(ApplicationInfo appInfo) in /home/<sanitized>/mip-filesdk-dotnet-core/src/Action.cs:line 86
   at mipsdk.Program.Main(String[] args) in /home/<sanitized>/mip-filesdk-dotnet-core/src/Program.cs:line 35
Aborted

The error persists if migrating to .NET 6 and happens in general with every .NET application trying to use Microsoft.InformationProtection.File under Ubuntu 20.04.

Minimal steps to reproduce

sudo apt-get install scons libgsf-1-dev libssl-dev libsecret-1-dev freeglut3-dev libcpprest-dev libcurl3-dev uuid-dev
git clone https://github.com/Azure-Samples/mip-filesdk-dotnet-core.git
# change the PackageReference to Microsoft.InformationProtection.File.Ubuntu2004 in mipsdk.csproj
dotnet build --output ../bin/Debug   [from src]
cd ../bin/Debug
./mipsdk

Ubuntu dependencies

given the dependencies for Ubuntu pointed out in the README,

sudo apt-get install scons libgsf-1-dev libssl-dev libsecret-1-dev freeglut3-dev libcpprest-dev libcurl3-dev uuid-dev

for slim docker images, these trigger the installation of a LOT of packages, is this necessary? I tried to skip that and got libmip_dotnet.so errors, is there a version that at least doesn't trigger the installation of a whole new Python 3.7?

The current docker image I use is python:3.9-slim-buster

also, I'm running a published release version for linux-x64 and framework-dependent publishing

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.