Skip to content

Commit

Permalink
update Dockerfiles for 2020-09-01-hybrid api profile (Azure#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOnlyWei authored Jun 4, 2021
1 parent e7f9849 commit ba66e89
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 19 deletions.
4 changes: 2 additions & 2 deletions docker/Dockerfile-centos-7
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ ARG AZURERM_CONTEXT_SETTINGS=AzureRmContextSettings.json
ARG AZURE=/root/.Azure
ARG VCS_REF="none"
ARG BUILD_DATE=
ARG VERSION=0.10.0
ARG VERSION=1.10.0
ARG IMAGE_NAME=mcr.microsoft.com/azure-stack-powershell:${VERSION}-centos-7
ARG AZURESTACK_PROFILE=2019-03-01-hybrid
ARG AZURESTACK_PROFILE=2020-09-01-hybrid
ARG AZURESTACK_VERSION=2.1.0
ARG READINESS_CHECKER_VERSION=1.2005.1269-preview

Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile-debian-9
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ ARG AZURERM_CONTEXT_SETTINGS=AzureRmContextSettings.json
ARG AZURE=/root/.Azure
ARG VCS_REF="none"
ARG BUILD_DATE=
ARG VERSION=0.10.0
ARG VERSION=1.10.0
ARG IMAGE_NAME=mcr.microsoft.com/azure-stack-powershell:${VERSION}-debian-9
ARG AZURESTACK_PROFILE=2019-03-01-hybrid
ARG AZURESTACK_PROFILE=2020-09-01-hybrid
ARG AZURESTACK_VERSION=2.1.0
ARG READINESS_CHECKER_VERSION=1.2005.1269-preview

Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile-ubuntu-18.04
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ ARG AZURERM_CONTEXT_SETTINGS=AzureRmContextSettings.json
ARG AZURE=/root/.Azure
ARG VCS_REF="none"
ARG BUILD_DATE=
ARG VERSION=0.10.0
ARG VERSION=1.10.0
ARG IMAGE_NAME=mcr.microsoft.com/azure-stack-powershell:${VERSION}-ubuntu-18.04
ARG AZURESTACK_PROFILE=2019-03-01-hybrid
ARG AZURESTACK_PROFILE=2020-09-01-hybrid
ARG AZURESTACK_VERSION=2.1.0
ARG READINESS_CHECKER_VERSION=1.2005.1269-preview

Expand Down
38 changes: 29 additions & 9 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@ The release containers derive from the [Powershell image][powershell image], and

AzureStack PowerShell [release notes](https://aka.ms/azspsdocker)

## Building Dockerfiles

Using `Dockerfile-ubuntu-18.04` as an example, here is the command to build the docker file and at the same time tagging it `mcr.microsoft.com/powershell:ubuntu-18.04`:

```sh
docker build -f .\Dockerfile-ubuntu-18.04 -t mcr.microsoft.com/powershell:ubuntu-18.04 .
```

Tagging images is useful for organizing your images. It is currently not possible to tag docker images within a dockerfile, so you will have to tag your image manually after its creation:

```sh
docker tag <image id> mcr.microsoft.com/powershell:ubuntu-18.04
```

`WARNING`: docker builds seem to break very easily. If it fails at first, try building it several times from a clean state. The `--no-cache` option ensures a clean build that doesn't use cached steps:

```sh
docker build -f .\Dockerfile-debian-9 -t mcr.microsoft.com/powershell:ubuntu-18.04 . --no-cache
```

## Examples

### Download/Update the AzureStack Powershell image
Expand All @@ -34,19 +54,19 @@ docker pull mcr.microsoft.com/azurestack/powershell:<tag>

### Run AzureStack Powershell container

- To run AzureStack Powershell in a container in an interactive mode:
- To run a new container with AzureStack resources from a docker image with Powershell Core as the interactive command interface:

```sh
$ docker run -it mcr.microsoft.com/azurestack/powershell:0.1.0-ubuntu-18.04 pwsh
```

- To run AzureStack Powershell in a container:
- To start an existing container containing AzureStack resources with Powershell Core as the interactive command interface:

```sh
$ docker start -ia mcr.microsoft.com/azurestack/powershell:0.1.0-ubuntu-18.04 pwsh
```

- To run AzureStack Powershell from using a container in an interactive mode using host authentication:
- To run a container containing AzureStack resources from a docker image in an interactive Powershell Core interface using host authentication:

1. Make sure that `$HOME/.Azure` is present on the host (default location).
2. You may need to grant access this location for the docker process.
Expand All @@ -64,7 +84,7 @@ docker run -it --rm -v ~/.Azure/AzureRmContext.json:/root/.Azure/AzureRmContext.
### Remove image

```sh
docker rmi mcr.microsoft.com/azurestack/powershell
docker rmi <image id>
```

### Testing
Expand All @@ -81,18 +101,18 @@ docker run
Login using credentials:
```sh
./Login-Environment.ps1
[-Name <String>] # Defaults to 'AzureStack'
[-EnvironmentName <String>] # Defaults to 'AzureStack'
-ResourceManagerEndpoint <System.Uri>
-DirectoryTenantId <String>
-TenantId <String>
-Credential <PSCredential>
[-SubscriptionId <String>]
```
Login using certificates:
```sh
./Login-Environment.ps1
[-Name <String>] # Defaults to 'AzureStack'
[-EnvironmentName <String>] # Defaults to 'AzureStack'
-ResourceManagerEndpoint <System.Uri>
-DirectoryTenantId <String>
-TenantId <String>
-ApplicationId <String>
-CertificateThumbprint <String>
[-SubscriptionId <String>]
Expand All @@ -110,7 +130,7 @@ Login using certificates:
```sh
./Test-AzsPowershell.ps1
[-ClientObjectId <String>] # Defaults to $ENV:ClientObjectId
[-resourceLocation <String>] # Defaults to $ENV:Location
[-Location <String>] # Defaults to $ENV:Location
```

## Developing and Contributing
Expand Down
8 changes: 4 additions & 4 deletions docker/scripts/Test-AzsPowershell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ param (
$ClientObjectId = $ENV:ClientObjectId,
[Parameter(HelpMessage = "The location of the resources for Azure Stack.")]
[string]
$resourceLocation = $ENV:Location
$Location = $ENV:Location
)

$resourceGroup = "azurestack-container-rg"
Expand Down Expand Up @@ -109,7 +109,7 @@ $TestAzKeyVault =
{
$KeyVaultName = "azurestackContainerKV"
Log -Message "Creating new key vault... (New-AzKeyVault)"
New-AzKeyVault -VaultName $KeyVaultName -ResourceGroupName $resourceGroup -Location $resourceLocation -Verbose -ErrorAction Stop
New-AzKeyVault -VaultName $KeyVaultName -ResourceGroupName $resourceGroup -Location $Location -Verbose -ErrorAction Stop
Get-AzKeyVault -VaultName $KeyVaultName -ErrorAction Stop
Set-AzKeyVaultAccessPolicy -VaultName $KeyVaultName -ResourceGroupName $resourceGroup -ObjectId $ClientObjectId -BypassObjectIdValidation -PermissionsToKeys all -PermissionsToSecrets all -ErrorAction Stop

Expand Down Expand Up @@ -171,7 +171,7 @@ $TestAzNetwork =
{
$networkSecurityGroup = "network-sg"
Log -Message "Running New-AzNetworkSecurityGroup..."
New-AzNetworkSecurityGroup -ResourceGroupName $resourceGroup -Name $networkSecurityGroup -Location $resourceLocation
New-AzNetworkSecurityGroup -ResourceGroupName $resourceGroup -Name $networkSecurityGroup -Location $Location
Log -Message "Running Get-AzNetworkSecurityGroup..."
Get-AzNetworkSecurityGroup -ResourceGroupName $resourceGroup -Name $networkSecurityGroup | Format-Table -AutoSize | Out-String | Log
Log -Message "Running Remove-AzNetworkSecurityGroup..."
Expand All @@ -190,7 +190,7 @@ $TestAzWebsites =
Log -Message "Running New-AzAppServicePlan..."
New-AzAppServicePlan -ResourceGroupName $resourceGroup `
-Name $appName `
-Location $resourceLocation `
-Location $Location `
-Tier "Free" `
-NumberofWorkers 1 `
-WorkerSize "Small" | Format-Table -AutoSize | Out-String | Log
Expand Down

0 comments on commit ba66e89

Please sign in to comment.