Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- param(
- $DockerUserName = "",
- $DockerPassword = "",
- $ShareUserName = "",
- $SharePassword = "",
- $ServicePrincipalName = "",
- $ServicePrincipalPassword = ""
- )
- $azurePassword = ConvertTo-SecureString $ServicePrincipalPassword -AsPlainText -Force
- $psCred = New-Object System.Management.Automation.PSCredential($ServicePrincipalName , $azurePassword)
- $storagePassword = ConvertTo-SecureString $SharePassword -AsPlainText -Force
- $storageCred = New-Object System.Management.Automation.PSCredential($ShareUserName , $storagePassword)
- $registryPassword = ConvertTo-SecureString $DockerPassword -AsPlainText -Force
- $registryCred = New-Object System.Management.Automation.PSCredential($DockerUserName , $registryPassword)
- Connect-AzAccount -ServicePrincipal -Credential $psCred -Force -TenantId myTenant.onmicrosoft.com
- Start-Sleep 2
- $Module = Import-Module Az -PassThru -ErrorAction SilentlyContinue
- if ($null -eq $Module)
- {
- Install-Module Az -Scope CurrentUser -Force
- }
- $Container = Get-AzContainerGroup -Name "container-name" -ResourceGroupName 'resource-group' -ErrorAction SilentlyContinue
- if ($null -ne $Container)
- {
- Remove-AzContainerGroup -InputObject $Container
- }
- $Params = @{
- ResourceGroupName = "resource-group"
- Name = "container-name"
- Cpu = 1
- MemoryInGB = 1.5
- Port = @(8080, 10001)
- DnsNameLabel = "container-name"
- OsType = 'Linux'
- Image = "adamdriscoll/myImage:1.0.1"
- AzureFileVolumeShareName ="my-storage"
- AzureFileVolumeAccountCredential = $storageCred
- AzureFileVolumeMountPath = "/home/config"
- EnvironmentVariable = @{
- ENVVAR = "Hello!"
- }
- RegistryCredential = $registryCred
- RegistryServerDomain = "index.docker.io"
- }
- New-AzContainerGroup @params
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement