Exemple #1
0
 public LocalRunner(string schemaPath, int port, ProjectRunArgs args, ImageCredentials image)
 {
     Port           = port;
     ProjectRunArgs = args;
     SchemaPath     = schemaPath;
     this.image     = image;
     watcher        = new FileSystemWatcher();
 }
Exemple #2
0
 public RemoteServiceManager(string tenantId, string subscriptionId, ImageCredentials image)
 {
     this.tenantId       = tenantId;
     this.subscriptionId = subscriptionId;
     this.image          = image;
 }
Exemple #3
0
        public static ContainerDeploymentTemplate CreateDeploymentTemplate(RemoteProject project, ImageCredentials image)
        {
            // see: https://docs.microsoft.com/en-us/azure/container-instances/container-instances-volume-azure-files
            var template = new ContainerDeploymentTemplate()
            {
                Schema         = "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                ContentVersion = "1.0.0.0",
                Variables      = new ContainerDeploymentTemplate.VariablesModel()
                {
                    ContainerImage = image.Name,
                    ContainerName  = project.AppId
                },
                Resources = new List <ContainerDeploymentTemplate.ResourceModel>()
                {
                    new ContainerDeploymentTemplate.ResourceModel()
                    {
                        Name       = project.AppId,
                        Type       = "Microsoft.ContainerInstance/containerGroups",
                        ApiVersion = "2019-12-01",
                        Location   = "[resourceGroup().location]",
                        Properties = new ContainerDeploymentTemplate.PropertiesModel()
                        {
                            Containers = new List <ContainerDeploymentTemplate.ContainerModel>()
                            {
                                new ContainerDeploymentTemplate.ContainerModel()
                                {
                                    Name       = "[variables('containerName')]",
                                    Properties = new ContainerDeploymentTemplate.ContainerPropertiesModel()
                                    {
                                        Image     = "[variables('containerImage')]",
                                        Resources = new ContainerDeploymentTemplate.ContainerResourcesModel()
                                        {
                                            Requests = new ContainerDeploymentTemplate.ContainerResourceRequestsModel()
                                            {
                                                Cpu        = 1,
                                                MemoryInGb = 1.5
                                            }
                                        },
                                        Ports = new List <ContainerDeploymentTemplate.PortModel>()
                                        {
                                            new ContainerDeploymentTemplate.PortModel()
                                            {
                                                Port     = 80,
                                                Protocol = "tcp"
                                            }
                                        },
                                        VolumeMounts = new List <ContainerDeploymentTemplate.ContainerVolumeMountModel>()
                                        {
                                            new ContainerDeploymentTemplate.ContainerVolumeMountModel()
                                            {
                                                Name      = $"vol{project.AppId}",
                                                MountPath = "/mnt/data"
                                            }
                                        },
                                        EnvironmentVariables = new List <ContainerDeploymentTemplate.ContainerEnvironmentVariableModel>()
                                        {
                                            new ContainerDeploymentTemplate.ContainerEnvironmentVariableModel()
                                            {
                                                Name  = "IS_REMOTE_ENV",
                                                Value = "true"
                                            },
                                            new ContainerDeploymentTemplate.ContainerEnvironmentVariableModel()
                                            {
                                                Name  = "SEED_DATA",
                                                Value = project.SeedData ? "true" : "false"
                                            },
                                            new ContainerDeploymentTemplate.ContainerEnvironmentVariableModel()
                                            {
                                                Name  = "AZURE_FILE_SHARE_NAME",
                                                Value = project.AzureFileShare
                                            },
                                            new ContainerDeploymentTemplate.ContainerEnvironmentVariableModel()
                                            {
                                                Name  = "AZURE_STORAGE_CONNECTION_STRING",
                                                Value = project.StorageConnectionString
                                            },
                                            new ContainerDeploymentTemplate.ContainerEnvironmentVariableModel()
                                            {
                                                Name  = "AZURE_FILE_CSDL_DIR",
                                                Value = "schema"
                                            },
                                            new ContainerDeploymentTemplate.ContainerEnvironmentVariableModel()
                                            {
                                                Name  = "AZURE_FILE_CSDL_FILE",
                                                Value = "Project.csdl"
                                            }
                                        }
                                    }
                                }
                            },
                            OsType    = "Linux",
                            IpAddress = new ContainerDeploymentTemplate.IpAddressModel()
                            {
                                Type  = "Public",
                                Ports = new List <ContainerDeploymentTemplate.PortModel>()
                                {
                                    new ContainerDeploymentTemplate.PortModel()
                                    {
                                        Protocol = "tcp",
                                        Port     = 80
                                    }
                                },
                                DnsNameLabel = project.AppId
                            },
                            Volumes = new List <ContainerDeploymentTemplate.VolumeModel>()
                            {
                                new ContainerDeploymentTemplate.VolumeModel()
                                {
                                    Name      = $"vol{project.AppId}",
                                    AzureFile = new ContainerDeploymentTemplate.AzureFileModel()
                                    {
                                        ShareName          = project.AzureFileShare,
                                        StorageAccountKey  = project.StorageAccountKey,
                                        StorageAccountName = project.StorageAccountName
                                    }
                                }
                            },
                            ImageRegistryCredentials = new List <ContainerDeploymentTemplate.ImageRegistryCredentialsModel>()
                            {
                                new ContainerDeploymentTemplate.ImageRegistryCredentialsModel()
                                {
                                    Server   = image.Server,
                                    Username = image.Username,
                                    Password = image.Password
                                }
                            }
                        }
                    }
                }
            };

            return(template);
        }
Exemple #4
0
 public ServiceUpdater(ImageCredentials image)
 {
     this.image = image;
 }