Skip to content

Commit

Permalink
Merge pull request #1 from JMayrbaeurl/registryadd
Browse files Browse the repository at this point in the history
Add Registry service implementation
  • Loading branch information
JMayrbaeurl authored Jan 20, 2022
2 parents 4dc1583 + 0a52a94 commit ebf7663
Show file tree
Hide file tree
Showing 43 changed files with 5,859 additions and 84 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/build-and-publish-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ jobs:
- name: Image digest for Discovery Server
run: echo ${{ steps.docker_build.outputs.digest }}

- name: Build image for Registry Server and push to Docker Hub
uses: docker/build-push-action@v2
with:
# relative path to the place where source code with Dockerfile is located
context: .
file: src/aas-api-webapp-registry/Dockerfile
# Note: tags has to be all lower-case
tags: |
jmayrbaeurl/aas-registry-server:latest
# build on feature branches, push only on main branch
push: ${{ github.ref == 'refs/heads/master' }}

- name: Image digest for Registry Server
run: echo ${{ steps.docker_build.outputs.digest }}

- name: Build image for Full Server and push to Docker Hub
uses: docker/build-push-action@v2
with:
Expand Down
24 changes: 21 additions & 3 deletions AAS API on Azure.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31911.196
# Visual Studio Version 17
VisualStudioVersion = 17.0.32112.339
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AAS WebApp Repository", "src\aas-api-webapp-repository\AAS WebApp Repository.csproj", "{37E281C2-FC84-4BD9-AFB5-AC55A9D92B0F}"
ProjectSection(ProjectDependencies) = postProject
Expand Down Expand Up @@ -32,7 +32,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AAS AASX File Service", "sr
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AAS AASX File Service Tests", "src\aas-aasxfile-service-tests\AAS AASX File Service Tests.csproj", "{82A9C310-4E09-4FD7-B3DB-F9E6C670A536}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AAS WebApp Discovery", "src\aas-api-webapp-discovery\AAS WebApp Discovery.csproj", "{F54DA57A-DC54-4F84-A0C7-0ED10B60C226}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AAS WebApp Discovery", "src\aas-api-webapp-discovery\AAS WebApp Discovery.csproj", "{F54DA57A-DC54-4F84-A0C7-0ED10B60C226}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AAS Registry Service", "src\aas-registry-service\AAS Registry Service.csproj", "{0D0AD4E2-C76D-43F7-B62E-6D386DF2A93E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AAS Registry Service Tests", "src\aas-registry-service-tests\AAS Registry Service Tests.csproj", "{A4F5E0BC-2400-422E-9D38-6B82BB3E1347}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AAS WebApp Registry", "src\aas-api-webapp-registry\AAS WebApp Registry.csproj", "{B3AA9231-9B5E-4A71-AE05-57A687CD9097}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -84,6 +90,18 @@ Global
{F54DA57A-DC54-4F84-A0C7-0ED10B60C226}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F54DA57A-DC54-4F84-A0C7-0ED10B60C226}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F54DA57A-DC54-4F84-A0C7-0ED10B60C226}.Release|Any CPU.Build.0 = Release|Any CPU
{0D0AD4E2-C76D-43F7-B62E-6D386DF2A93E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0D0AD4E2-C76D-43F7-B62E-6D386DF2A93E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0D0AD4E2-C76D-43F7-B62E-6D386DF2A93E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0D0AD4E2-C76D-43F7-B62E-6D386DF2A93E}.Release|Any CPU.Build.0 = Release|Any CPU
{A4F5E0BC-2400-422E-9D38-6B82BB3E1347}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A4F5E0BC-2400-422E-9D38-6B82BB3E1347}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A4F5E0BC-2400-422E-9D38-6B82BB3E1347}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A4F5E0BC-2400-422E-9D38-6B82BB3E1347}.Release|Any CPU.Build.0 = Release|Any CPU
{B3AA9231-9B5E-4A71-AE05-57A687CD9097}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B3AA9231-9B5E-4A71-AE05-57A687CD9097}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B3AA9231-9B5E-4A71-AE05-57A687CD9097}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B3AA9231-9B5E-4A71-AE05-57A687CD9097}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Binary file added Assets/images/AzureIIoTHeroscenarioRefArch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ using [Azure Blob Storage](https://azure.microsoft.com/en-us/services/storage/bl
in a container called `aasxfiles`. The name of the container to be used can be configured. If the container doesn't exist in the Blob storage account,
it will be created automatically. For each package a folder with the file name without the file extension will be created in the container.
Samples from [AASX Browser](https://admin-shell-io.com/5001/) were used for testing.
- **AAS Discovery server**: See 'aas-api-webapp-discovery' folder in 'src'. Not implemented yet.
- **AAS Shell Repository server**: See 'aas-api-webapp-repository' folder in 'src'.
- **AAS Discovery server**: See 'aas-api-webapp-discovery' folder in 'src'. Partially implemented.
- **AAS Registry server**: See 'aas-api-webapp-registry' folder in 'src'. Partially implemented.
- **AAS Shell Repository server**: See 'aas-api-webapp-repository' folder in 'src'. Partially implemented.
- **AAS Full server**: See 'aas-api-webapp-full' folder in 'src'. Implementation of the entire interface collection as part of
[Details of the Asset Administration Shell Part 2](https://www.plattform-i40.de/IP/Redaktion/EN/Downloads/Publikation/Details_of_the_Asset_Administration_Shell_Part2_V1.pdf)

![Sample Architecture](Assets/images/AzureIIoTHeroscenarioRefArch.png)

## Security
All servers use [Default Azure credentials](https://docs.microsoft.com/en-us/dotnet/api/overview/azure/identity-readme)
for authorization ([Managed Identities](https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview))
Expand Down Expand Up @@ -51,6 +54,9 @@ to the AASX File server. E.g. by leveraging its Managed Identity of the App serv
## AAS Discovery server
TBD

## AAS Registry server
TBD

## AAS Shell Repository server
TBD

Expand Down
11 changes: 11 additions & 0 deletions scripts/azuredeployment/aasapiservicestdroles.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"allowedMemberTypes": [
"Application"
],
"description": "Contributors have to right to read and write AAS objects",
"displayName": "AAS Contributor",
"isEnabled": true,
"value": "AAS.ReadWrite"
}
]
22 changes: 22 additions & 0 deletions scripts/azuredeployment/createAzureDigitalTwinsInstance.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Create Azure Digital Twin instance for the Shell and Discovery service
# uses the currently selected Azure subscription. Azure CLI version 2.14.0 or higher.

param (
[string] $dcloc = "West Europe",
[string] $rg = "aas-sample-rg",
[string] $dtName = "aasrepositorydigitaltwins"
)

# 1. Check existenc of resource group and create it if it's not existing yet
$rsgExists = az group exists -n $rg
if ( $rsgExists -eq 'false') {
Write-Host "Resource group " $rg " doesn't exist. Creating it now."
az group create -l $dcloc -n $rg
}

# 2. Create Azure Digital Twin instance
az dt create --dt-name $dtName -g $rg -l $dcloc --assign-identity true

# 3. Create ADT Data Owner role for current user
$currAcc = $(az account show) | ConvertFrom-Json
az dt role-assignment create --dt-name $dtName -g $rg --assignee $currAcc.user.name --role "Azure Digital Twins Data Owner"
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Create Azure Redis Cache DB for the AAS Registry service
# uses the currently selected Azure subscription. Azure CLI version 2.14.0 or higher.
# Will create an Azure Redis Cache DB (Basic C0).
# If parameter 'appName' contains a valid Web App name in the same resource group, it will
# automatically set the Web Apps config para 'AASREGISTRYCACHECONNSTRING' to the connection
# string of the created Redis Cache DB.

param (
[string] $dcloc = "West Europe",
[string] $rg = "aas-sample-rg",
[string] $cacheName = "aasregistrycache",
[string] $cacheSku = "Basic",
[string] $cacheVmSize = "c0",
[string] $appName
)

# 1. Check existenc of resource group and create it if it's not existing yet
$rsgExists = az group exists -n $rg
if ( $rsgExists -eq 'false') {
Write-Host "Resource group " $rg " doesn't exist. Creating it now."
az group create -l $dcloc -n $rg
}

# 2. Create Redis Cache if it doesn't exist yet
$existingCaches=$(az redis list --query "[?name=='$cacheName']")
if ( $$existingCaches.length == 0) {
Write-Host "Redis cache with name " $cacheName " doesn't exist. Creating it now"

$redis=$(az redis create --location $dcloc --name $cacheName -g $rg `
--sku $cacheSku --vm-size $cacheVmSize --redis-version 6 --query [hostName,sslPort] --output tsv)

# 3. Get connection string
$key=$(az redis list-keys --name $cacheName -g $rg --query primaryKey --output tsv)
$connString=$redis[0] + ":" + $redis[1] + ",password=" + $key + ",ssl=True,abortConnect=False"
Write-Host "Redis cache connection string: " $connString

# 4. Assign the connection string to an App Setting in the Web App
if (-not $appName)
az webapp config appsettings set --name $appName -g $rg --settings "AASREGISTRYCACHECONNSTRING=$connString"
}
41 changes: 41 additions & 0 deletions scripts/azuredeployment/createAzureStorageForAASXFileServer.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Create Azure storage account for an AASX File Server
# uses the currently selected Azure subscription. Azure CLI version 2.14.0 or higher.
# Will create an ADLS storage account with hierarchical namespaces

param (
[string] $dcloc = "West Europe",
[string] $rg = "aas-sample-rg",
[string] $storageAccName = "aasxfileserverstorage",
[string] $storageSku = "Standard_LRS"
)

# 1. Check existenc of resource group and create it if it's not existing yet
$rsgExists = az group exists -n $rg
if ( $rsgExists -eq 'false') {
Write-Host "Resource group " $rg " doesn't exist. Creating it now."
az group create -l $dcloc -n $rg
}

# 2. Create Azure storage account if not exists yet
$storageAccExists = $(az storage account check-name --name $storageAccName) | ConvertFrom-Json
if ( $storageAccExists.nameAvailable ) {
Write-Host "Storage account " $storageAccName " doesn't exist. Creating it now."
az storage account create -n $storageAccName -g $rg -l $dcloc --access-tier Hot --sku $storageSku --kind "StorageV2" `
--allow-blob-public-access false --allow-shared-key-access false --enable-hierarchical-namespace true
}

# 3. Create container for AASX file packages
$contExists = $(az storage container exists --name aasxfiles --account-name $storageAccName --auth-mode login) | ConvertFrom-Json
if (-not($contExists.exists) ) {
Write-Host "Container for AASX packages doesn't exist. Creating it now."
az storage container create --name aasxfiles --account-name $storageAccName --auth-mode login
}

# 4. Assign roles to creating user
$currAcc = $(az account show) | ConvertFrom-Json
$storageAccId = $(az storage account show -n $storageAccName -g $rg --query id)
az role assignment create --role "Storage Blob Data Owner" --assignee $currAcc.user.name --scope $storageAccId

# 5. Set correct access
# $oldContAcc = $(az storage fs access show --account-name $storageAccName --file-system aasxfiles --path . --auth-mode login)
az storage fs access set --acl "user::rwx,group::r-x,other::r-x" --path . -f aasxfiles --account-name $storageAccName --auth-mode login
34 changes: 34 additions & 0 deletions scripts/azuredeployment/createWebApiAppForService.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Create Azure Web Api app for AAS Services
# uses the currently selected Azure subscription. Azure CLI version 2.14.0 or higher.

param (
[string] $dcloc = "West Europe",
[string] $rg = "aas-sample-rg",
[string] $planName = "aasappserviceplan",
[string] $planSku = "B1",
[string] $appName = "aasapiservice"
)

# 1. Check existenc of resource group and create it if it's not existing yet
$rsgExists = az group exists -n $rg
if ( $rsgExists -eq 'false') {
Write-Host "Resource group " $rg " doesn't exist. Creating it now."
az group create -l $dcloc -n $rg
}

# 2. Create App service plan if it doesn't exist yet
$existingPlan=$(az appservice plan list -g $rg --query "[?name=='$planName']")
if ($existingPlan.length == 0) {
az appservice plan create --name $planName --g $rg --location $dcloc --is-linux --sku $planSku
}

# 3. Create Web app
az webapp create -g $rg -p $planName -n $appName --runtime "DOTNETCORE|3.1" --assign-identity

# TODO Set 'kind' to "linux,api" with 'az resource update' to enable API features in portal

# 4. Create App registration for Web app
$clientId = $(az ad app create --display-name $appName --available-to-other-tenants false --app-roles @aasapiservicestdroles.json --query appId -o tsv)

# 5. Set Azure AD configurtion in Web app
az webapp config appsettings set --name $appName -g $rg --settings "AzureAd__ClientId=$clientId"
13 changes: 11 additions & 2 deletions src/aas-api-models/Interfaces/Registry.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
using System;
using AAS.API.Models;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace AAS.API.Interfaces
{
public interface Registry
{
public Task<List<AssetAdministrationShellDescriptor>> GetAllAssetAdministrationShellDescriptors();

public Task<AssetAdministrationShellDescriptor> GetAssetAdministrationShellDescriptorById(string aasIdentifier);

public Task<AssetAdministrationShellDescriptor> CreateAssetAdministrationShellDescriptor(AssetAdministrationShellDescriptor aasDesc);

public Task UpdateAssetAdministrationShellDescriptorById(AssetAdministrationShellDescriptor aasDesc, string aasIdentifier);

public Task DeleteAssetAdministrationShellDescriptorById(string aasIdentifier);
}
}
19 changes: 19 additions & 0 deletions src/aas-api-models/Interfaces/SubmodelRegistry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using AAS.API.Models;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace AAS.API.Interfaces
{
public interface SubmodelRegistry
{
public Task<List<SubmodelDescriptor>> GetAllSubmodelDescriptors();

public Task<SubmodelDescriptor> GetSubmodelDescriptorById(string submodelIdentifier);

public Task<SubmodelDescriptor> CreateSubmodelDescriptor(SubmodelDescriptor submodelDescriptor);

public Task UpdateSubmodelDescriptorById(string submodelIdentifier, SubmodelDescriptor submodelDescriptor);

public Task DeleteSubmodelDescriptorById(string idsubmodelIdentifier);
}
}
2 changes: 2 additions & 0 deletions src/aas-api-webapp-full/AAS WebApp full.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<AssemblyName>AASAPIServerFull</AssemblyName>
<PackageId>AASAPIServerFull</PackageId>
<RootNamespace>AAS.API.Server.Full</RootNamespace>
<UserSecretsId>bf8383c6-1e08-4107-b128-89b6ddb0562f</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Azure" Version="1.1.1" />
Expand All @@ -28,6 +29,7 @@
<ProjectReference Include="..\aas-aasxfile-service\AAS AASX File Service.csproj" />
<ProjectReference Include="..\aas-api-models\AAS API Models.csproj" />
<ProjectReference Include="..\aas-discovery-service\AAS Discovery Service.csproj" />
<ProjectReference Include="..\aas-registry-service\AAS Registry Service.csproj" />
<ProjectReference Include="..\aas-repository\AAS Repository.csproj" />
</ItemGroup>
</Project>
Loading

0 comments on commit ebf7663

Please sign in to comment.